typestrong / ntypescript Goto Github PK
View Code? Open in Web Editor NEWNicer TypeScript for API devs
Home Page: https://www.npmjs.com/package/ntypescript
License: Other
Nicer TypeScript for API devs
Home Page: https://www.npmjs.com/package/ntypescript
License: Other
I often need to work locally on ntypescript
inside another project. Currently you need to work on the generated .js
which is slow and messy and a bit out of context
Using [email protected]. This version may or may not be compatible with ts-loader.
The message always shows when I running my webpack.
Well, I use this compiler because the tsconfig.json is too complicated and I would get the 10082 error message so I chose this compiler, but shows the message above, please show me a way to correct the configurations, thanks.
ntsc seems to be missing the --alwaysStrict flag. Was this intentional or has it not been updated yet?
@basarat Hello, thanks for the great package!
I have one question. The latest build was 6 days ago. I thought the idea was to publish 'nightly' builds periodically using Travis or something like that. Something is broken?
It looks like that an error is in the file:
function isTemplateLiteralKind(kind: SyntaxKind): boolean;
function isBindingPattern(node: Node): ;
function isInAmbientContext(node: Node): boolean;
@basarat Hello, thanks for the great package! It's very convinient tool!
I have issue which don't face before. I start new ts project on another PC. (install npm, ntypescript, tsd)
added tsx, ts files to project. setted out compiler option. In result of compilation I see that compiled file contains only definitions from *.ts files. but tsx compiled to the same directory as tsx file.
atteched screen https://www.dropbox.com/s/90c3r4a1vjikz4j/ntypescriptIssue.png?dl=0.
Maybe a'm not correct?
Thank you!
NTypeScript is dead. Bring your own TypeScript https://github.com/basarat/byots 🌹
@basarat Please mention this in the README.
I'm not seeing any option that would make the compiled js code be minified. Is there an option for that that I'm just missing?
Hello @basarat !
I have question. In my project i use es6-promise library;
i installed d.ts for it.
in tsconfig added es6-promise
and in my main.ts expression
import {Promise} from "es6-promise";
is available.
But compiler say that 'Promise' contains in es6.lib,
we have conflict between 2 files es6.lib and es6-promise.d.ts.
do you have any idea how to resolve it?
i use latest ntypescript atom-typescript and ts-loader for webpack
Thank you!
see README : "Install"
or in your package.json
npm install ntypescript@latest --save --save-exact
Shouldn't it mention the package.json json member
here ?
The npm install
could become an extra line.
Just think it might be misleading for newbies...
It seems to totatly ignore the exclude configuration in the tsconfig.json and compiles as well the ignore files.
For instance I have the following configuration:
{
"compilerOptions": {
"target": "es5",
"module": "system",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules"
]
}
And it still compiles everything in the node_modules folder.
I am running it via node : npm run ntsc -w
AFAIK there are 3 files that need to be included: tsserver.js, tsserverlibrary.d.ts and tsserverlibrary.js.
For example let's say I want to use a newer TypeScript compiler than the one bundled with Jetbrains:
I understand that this is listed in your "Design incompatibilities" section of your README.md.
What is your reasoning for excluding it? - File size? - Any chance of convincing you to include it?
tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"module": "amd",
"jsx": "react"
},
"compileOnSave": false,
"files": [
"./main.tsx",
"./typings/tsd.d.ts"
]
}
tsd
:
tsd install react-global react-bootstrap --save
main.tsx
:
import * as React from 'react';
import { render } from 'react-dom';
import { Button } from 'react-bootstrap';
class App extends React.Component<{}, {}> {
render() {
return <Button bsSize="large" bsStyle="danger" > {"Button Text"} </Button>;
}
}
render(<App />, document.getElementsByTagName("entrypoint")[0] );
ntsc 1.201512090606.1
fails with these error messages
main.tsx(8,12): error TS2324: Property 'key' is missing in type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<ButtonProps, any>> & ButtonProps'.
main.tsx(8,12): error TS2324: Property 'ref' is missing in type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<ButtonProps, any>> & ButtonProps'.
The error message says that 'key' and 'props' property must be given, but they are defined as optional on IntrinsicAttributes and IntrinsicClassicAttributes like this.
in react.d.ts
, line 2119~2125
interface IntrinsicAttributes {
key?: string | number;
}
interface IntrinsicClassAttributes<T> {
ref?: string | ((classInstance: T) => void);
}
tsc
compiles main.tsx
without problem.
This bug makes atom-typescript plugin glitchy while writing react apps with typescript.
tsconfig.json:
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "javascript"
},
"files": [
"./typescript/main.ts",
"./typed/sha.js.d.ts"
],
"exclude": [
"node_modules"
]
}
main.ts:
/// <reference path="../typings/browser.d.ts"/>
import "angular2/bundles/angular2-polyfills";
import {bootstrap} from "angular2/platform/browser";
import {AppComponent} from "./app.component";
import {ROUTER_PROVIDERS} from "angular2/router";
bootstrap(AppComponent, [ROUTER_PROVIDERS]);
outcome from ntsc:
node_modules/ntypescript/bin/lib.d.ts(1266,14): error TS2300: Duplicate identifier 'PropertyKey'.
typings/browser/ambient/es6-shim/index.d.ts(8,14): error TS2300: Duplicate identifier 'PropertyKey'.
When I look at TypeScript's ES2015.core.d.ts I see ObjectConstructor's assign. I don't see it in the latest version of Atom's lib.d.ts though and get an error
See microsoft/TypeScript#5264 (comment) for details
One can be explicitly imported (perhaps typescript.definition
can link to it) that has both global + module.
One will be linked from typings
and will just export ts
as a module.
[08:06:22] gulp-notify: [Compile Error] TypeScript error: node_modules/ntypescript/bin/ntypescript.d.ts(6602,13): Error TS2403: Subsequent variable declarations must have the same type. Variable 'global' must be of type 'Global', but here has type 'any'.
--worked around the compile error by removing the declaration of global variable.
version: 1.201508070004.1
Any chance you could add async/await support to the es5 output mode? (aka convert them to promises)
Trying typescript-book/docs/compiler/parser.md#sample-usage:
import * as ts from "ntypescript";
function printAllChildren(node: ts.Node, depth = 0) {
console.log(new Array(depth + 1).join('----'),
ts.syntaxKindToName(node.kind), node.pos, node.end);
depth++;
node.getChildren().forEach(c=> printAllChildren(c, depth));
}
var sourceCode = `
var foo = 123;
`.trim();
var sourceFile = ts.createSourceFile('foo.ts', sourceCode, ts.ScriptTarget.ES5, true);
printAllChildren(sourceFile);
Even after running npm install ntypescript@latest --save --save-exact
, my IDE (Atom) complains with: Cannot find module 'ntypescript'
.
Looking around for a *.d.t.s
file, and couldn't find it :. How shall I proceed?
Thanks for all suggestions
I use ntypescript in webpack, mostly for 3rd party libraries. Recently I have added react
to my project and started to get errors for @types/react
:
ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(171,34): error TS1005: ',' expected.
ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(172,34): error TS1005: ',' expected.
ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,43): error TS1005: ']' expected.
ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,44): error TS1005: ';' expected.
ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,45): error TS1128: Declaration or statement expected.
ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,46): error TS1128: Declaration or statement expected.
ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,61): error TS1005: '(' expected.
ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2695,1): error TS1128: Declaration or statement expected.
The problematic source code lines (causing the first error) are:
// Base component for plain JS classes
class Component<P, S> implements ComponentLifecycle<P, S> {
constructor(props?: P, context?: any);
setState<K extends keyof S>(f: (prevState: S, props: P) => Pick<S, K>, callback?: () => any): void;
▲ The error points here
setState<K extends keyof S>(state: Pick<S, K>, callback?: () => any): void;
▲ ... and here
forceUpdate(callBack?: () => any): void;
render(): JSX.Element | null;
Is it caused by the fact that the type definition uses some syntax/features introduced in Typescript 2.2? Is there a workaround?
s/basarat/TypeStrong/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.