You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// A *self-contained* demonstration of the problem follows...// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.enumHTTPError{CLIENT_ERROR='CLIENT_ERROR',SERVER_ERROR='SERVER_ERROR',UNKNOWN_ERROR='UNKNOWN_ERROR',}// Example 1typeRequestErrorsMap=Readonly<Record<HTTPError,string>>;constrequestErrorsMap: RequestErrorsMap={CLIENT_ERROR: 'Client has problem.',SERVER_ERROR: 'Server has problem.',UNKNOWN_ERROR: 'Unknown problem occurs.',};declareconstindex: HTTPError;requestErrorsMap[index];// Example 1.1requestErrorsMap[indexas'CLIENT_ERROR'|'SERVER_ERROR'|'UNKNOWN_ERROR'];// Example1.2// Example 2typeEM={[KinHTTPError]: string;};constem: EM={CLIENT_ERROR: 'Client has problem.',SERVER_ERROR: 'Server has problem.',UNKNOWN_ERROR: 'Unknown problem occurs.',};declareconsti: HTTPError;em[i];// Example 2.1em[ias'CLIENT_ERROR'|'SERVER_ERROR'|'UNKNOWN_ERROR'];// Example2.2
Expected behavior:
example 1.1, 1.2, 2.1 and 2.2 pass type check
Actual behavior:
only 1.2 and 2.2 pass type check
This makes an issue when dealing with js libraries. (whose type is from lib def file)
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.4.2
Code
Run following code with
--noImplicitAny
option.Expected behavior:
example 1.1, 1.2, 2.1 and 2.2 pass type check
Actual behavior:
only 1.2 and 2.2 pass type check
This makes an issue when dealing with js libraries. (whose type is from lib def file)
The text was updated successfully, but these errors were encountered: