question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

typescript compilerOptions not reflected

See original GitHub issue

Cypress TypeScript compilator probably do not reflects some of compilerOptions. In my case it looks like e.g. strict is ignored.

I am sure that my tsconfig.json is the one which is used because e.g. I have forgotten "noEmitHelpers": true and it raised errors so I needed to remove it.

It was working with webpack compiler.

Current behavior:

tsconfig.json:

{
    "compilerOptions": {
        "strict": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "noImplicitAny": true,
        "strictPropertyInitialization": true,
        "preserveConstEnums": false,
        "target": "es5",
        "lib": ["es5", "dom", "es2015.core", "es2015.promise", "es2015.iterable", "es2015.collection"],
        "types": ["cypress"],
        "sourceMap": true,
        "removeComments": false
    },
    "include": ["**/*.ts"]
}

test:

describe("example", () => {
    it("example", () => {
        let a: boolean | undefined;
        let b: boolean = a;
        console.log(b);
    });
});

VS Code reflects tsconfig.json and shows error:

Type 'boolean | undefined' is not assignable to type 'boolean'.
Type 'undefined' is not assignable to type 'boolean'.ts(2322)

Cypress run doesn’t reflects tsconfig.json and successfully compiles script.

Desired behavior:

Cypress also reflects tsconfig.json and shows error:

Type 'boolean | undefined' is not assignable to type 'boolean'.
Type 'undefined' is not assignable to type 'boolean'.ts(2322)

Versions

4.5.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:26 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
keeemacommented, Sep 17, 2020

I still don’t understand where is the problem in allowing it. I am developer so I should decide whether I prefer faster build or safer build. Web-pack pre-processor is just another unnecessary configuration I have to maintain…

4reactions
chrisbreidingcommented, Sep 11, 2020

In regards to the original issue, Cypress now supports most compiler options for spec files, but will continue to only transpile files by default and not type check them for performance reasons, so setting "strict": true will have no effect.

We do not plan to add a global option to configure this, as it can be accomplished through the preprocessor API.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are these tsconfig paths not working? - Stack Overflow
In case anyone is using VSCode and having trouble getting the /* solution to work. Try Cmd+Shift+P > Typescript: Restart TS Server. –...
Read more >
TSConfig Reference - Docs on every TSConfig option
A TSConfig file in a directory indicates that the directory is the root of a TypeScript or JavaScript project... Compiler Options. Top Level....
Read more >
Common TypeScript module problems and how to solve them
Solution 1: Locate the correct directory​​ When we use this configuration, TypeScript compiler “jumps” up a directory from the src directory and ...
Read more >
TypeScript errors and how to fix them
TypeScript does not allow statements in such ambient context declaration which ... the reflect-metadata package to shim the upcoming Metadata Reflection API ...
Read more >
Understanding TypeScript Configuration Options
When allowJs is true , TypeScript will allow JavaScript files to be compiled but, it will not do type-checking. Here's some example file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found