4 ms·
> ...TypeScript doesn't purport to analyze the correctness of regions of code that lack type annotations. TypeScript infers the types of local variables. For e
by jvilk 12y ago
> ...TypeScript doesn't purport to analyze the correctness of regions of code that lack type annotations.
TypeScript infers the types of local variables. For example, the following unannotated code would cause the TypeScript type checker to fail:
// error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
[1, 2, 3].join(4);
However, even when the TypeScript typechecker fails, TypeScript still produces JavaScript output. As a result, you can use TypeScript to incrementally type your program, and simply choose to ignore type checking errors. TypeScript only fails to produce output if there's a syntax error, or if you are using TypeScript import statements without specifying a module type.