Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Complete list of Typescript error codes and their fixes

Tags:

typescript

In Typescript, where do I find a complete reference of all error codes and their fixes.

My usecase is that I often see errors when compiling. for example:

data_loader_service.ts(10,13): error TS1005: '=>' expected.
data_loader_service.ts(10,24): error TS1144: '{' or ';' expected.
data_loader_service.ts(10,27): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
data_loader_service.ts(14,1): error TS1128: Declaration or statement expected.

I am looking for a place where I can easily lookup the error codes, e.g. TS1068 and read about the typical error and the typical fixes.

I am inspired by, for instance Jscs, which give nice overviews of all potential error codes.

Example from Jscs: http://jscs.info/rules

I am accepting responses that refer to either sourcecode or a finer webpage like the jscs example.

I expect you post an answer regarding the new Typescript (currently 1.6 is the most recent).

like image 832
Jesper Rønn-Jensen Avatar asked Oct 29 '15 09:10

Jesper Rønn-Jensen


People also ask

How do I find all the TypeScript errors?

You can add a type-check command in the NPM scripts: "scripts": { "type-check": "tsc", ... }, This runs only the type-checking and will report all errors.

What are TypeScript errors?

Whenever TypeScript finds an error, it tries to explain what went wrong in as much detail as possible. Because its type system is structural, this often means providing somewhat lengthy descriptions of where it found a problem.

How do I bypass TypeScript error?

Use // @ts-ignore to ignore the type checking errors on the next line in a TypeScript file. If you use a linter, you might have to add a comment to also suppress linting errors when using ts-ignore - // eslint-disable-next-line @typescript-eslint/ban-ts-comment .


1 Answers

Looking at the 1.6.2 sources of the compiler, tsc.js, tsserver.js, typescript.js and typescriptServices.js, a variable called ts.Diagnostics is initialized with a dictionary of all the error codes.

List of codes and definitions of 1.6.2 (unfortunately ugly formatted): https://github.com/Microsoft/TypeScript/blob/v1.6.2/src/compiler/diagnosticInformationMap.generated.ts

A slightly prettier format is available: https://github.com/Microsoft/TypeScript/blob/v1.6.2/src/compiler/diagnosticMessages.json

EDIT

Link to 1.8.5 errors: https://github.com/Microsoft/TypeScript/blob/v1.8.5/src/compiler/diagnosticMessages.json

like image 60
Bruno Grieder Avatar answered Oct 12 '22 02:10

Bruno Grieder