Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Finished] TypeScript conversion #1806

Merged
merged 35 commits into from
Dec 23, 2017
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
665f98c
lay foundations for TypeScript conversion
Rich-Harris Aug 21, 2017
0c0edee
initial naive typscript conversion
guybedford Dec 19, 2017
aa961e5
deep dive into ast folder!
guybedford Dec 19, 2017
b461965
ast folder types, complete estree definitions
guybedford Dec 20, 2017
f6cd52a
finish porting Rich Harris branch
guybedford Dec 20, 2017
fb3a34c
moar types
guybedford Dec 20, 2017
63d38d4
Add editorconfig file
lukastaegert Dec 20, 2017
f4619a0
Add some types for Module.ts (WIP)
lukastaegert Dec 20, 2017
4b448e5
ast type fixing
guybedford Dec 20, 2017
b561a63
More types for Module.ts (WIP)
lukastaegert Dec 20, 2017
3e4519d
add bin, browser, utils, initial watch types
guybedford Dec 20, 2017
c5da226
attempt finalisers, scopes, variables
guybedford Dec 20, 2017
9891e4a
Make JSDoc a little happier
lukastaegert Dec 21, 2017
b2210b9
finish up bin types, attempt further scopes and variables
guybedford Dec 21, 2017
70e565b
More Module typing
lukastaegert Dec 21, 2017
f36de4c
Finish typing Module.js
lukastaegert Dec 21, 2017
2a9db67
Mark private methods and variables
lukastaegert Dec 21, 2017
2d1b871
Type ExternalModule
lukastaegert Dec 21, 2017
58b92d9
Type Bundle (WIP)
lukastaegert Dec 21, 2017
265d646
complete types on bin, finalisers
guybedford Dec 21, 2017
cf49dc9
further attempts on Bundle
guybedford Dec 21, 2017
e1615cf
type tweaks
guybedford Dec 21, 2017
e71c9ec
module, bundle, finalisers polishing
guybedford Dec 21, 2017
f10abfb
A little more work on Bundle
lukastaegert Dec 21, 2017
26ba833
Type transformBundle
lukastaegert Dec 21, 2017
8079970
options refactor, bin and watch types complete
guybedford Dec 22, 2017
2d7f38e
more progress on variables and scopes
guybedford Dec 22, 2017
2d61040
node, variable polishes
guybedford Dec 22, 2017
aa5a63e
mergeOptions rename
guybedford Dec 22, 2017
bea8b7e
options types
guybedford Dec 22, 2017
ba25afe
Unify forEach callback signatures + more types
lukastaegert Dec 22, 2017
e4d1e38
Use UNKNOWN_ASSIGNMENT instead of UNDEFINED_ASSIGNMENT as it is basic…
lukastaegert Dec 22, 2017
39cce93
Finish typing!
lukastaegert Dec 22, 2017
3a70b47
remove callable expression abstraction, was only necessary to make ty…
guybedford Dec 23, 2017
ad8484b
downlevel iteration not necessary
guybedford Dec 23, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*.ts]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = 2

[*.md]
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Place your settings in this file to overwrite default and user settings.
{
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.insertSpaceAfterConstructor": true,
"typescript.format.enable": true
}
6 changes: 6 additions & 0 deletions bin/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'minimist';
declare module 'help.md' {
let str: string;
export default str;
}
declare module 'package.json';
44 changes: 0 additions & 44 deletions bin/src/index.js

This file was deleted.

42 changes: 42 additions & 0 deletions bin/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/// <reference path="./index.d.ts" />

import minimist from 'minimist';
import help from 'help.md';
import { version } from 'package.json';
import run from './run/index.js';

const command = minimist(process.argv.slice(2), {
alias: {
// Aliases
strict: 'useStrict',

// Short options
c: 'config',
d: 'indent',
e: 'external',
f: 'output.format',
g: 'globals',
h: 'help',
i: 'input',
l: 'legacy',
m: 'sourcemap',
n: 'name',
o: 'output.file',
v: 'version',
w: 'watch'
}
});

if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) {
console.log(`\n${help.replace('__VERSION__', version)}\n`); // eslint-disable-line no-console
} else if (command.version) {
console.log(`rollup version ${version}`); // eslint-disable-line no-console
} else {
try {
require('source-map-support').install();
} catch (err) {
// do nothing
}

run(command);
}
36 changes: 0 additions & 36 deletions bin/src/logging.js

This file was deleted.

42 changes: 42 additions & 0 deletions bin/src/logging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import chalk from 'chalk';
import relativeId from '../../src/utils/relativeId.js';
import { RollupError } from '../../src/utils/error';

if (!process.stderr.isTTY) chalk.enabled = false;

// log to stderr to keep `rollup main.js > bundle.js` from breaking
export const stderr = console.error.bind(console); // eslint-disable-line no-console

export function handleError (err: RollupError, recover = false) {
let description = err.message || err;
if (err.name) description = `${err.name}: ${description}`;
const message =
((<{ plugin?: string }>err).plugin ? `(${(<{ plugin?: string }>err).plugin} plugin) ${description}` : description) || err;

stderr(chalk.bold.red(`[!] ${chalk.bold(message.toString())}`));

// TODO should this be "err.url || (err.file && err.loc.file) || err.id"?
if (err.url) {
stderr(chalk.cyan(err.url));
}

if (err.loc) {
stderr(
`${relativeId(err.loc.file || err.id)} (${err.loc.line}:${
err.loc.column
})`
);
} else if (err.id) {
stderr(relativeId(err.id));
}

if (err.frame) {
stderr(chalk.dim(err.frame));
} else if (err.stack) {
stderr(chalk.dim(err.stack));
}

stderr('');

if (!recover) process.exit(1);
}
1 change: 1 addition & 0 deletions bin/src/run/alternateScreen.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "ansi-escapes";
22 changes: 12 additions & 10 deletions bin/src/run/alternateScreen.js → bin/src/run/alternateScreen.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
/// <reference path="./alternateScreen.d.ts" />

import ansiEscape from 'ansi-escapes';
import { stderr } from '../logging.js';

const SHOW_ALTERNATE_SCREEN = '\u001B[?1049h';
const HIDE_ALTERNATE_SCREEN = '\u001B[?1049l';

export default function alternateScreen ( enabled ) {
export default function alternateScreen (enabled: boolean) {
if (!enabled) {
let needAnnounce = true;
return {
open() {},
close() {},
reset( heading ) {
if ( needAnnounce ) {
stderr( heading );
open () { },
close () { },
reset (heading: string) {
if (needAnnounce) {
stderr(heading);
needAnnounce = false;
}
}
};
}

return {
open() {
open () {
process.stderr.write(SHOW_ALTERNATE_SCREEN);
},
close() {
close () {
process.stderr.write(HIDE_ALTERNATE_SCREEN);
},
reset( heading ) {
stderr( `${ansiEscape.eraseScreen}${ansiEscape.cursorTo(0, 0)}${heading}` );
reset (heading: string) {
stderr(`${ansiEscape.eraseScreen}${ansiEscape.cursorTo(0, 0)}${heading}`);
}
};
}