mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge branch 'master' of https://github.com/DefinitelyTyped/DefinitelyTyped into jquery/promise-compatibility
This commit is contained in:
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
// Type definitions for react-table-filter 1.0.0
|
||||
// Project: https://github.com/cheekujha/react-table-filter
|
||||
// Definitions by: Gnanavel N <https://github.com/gjsln/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
export interface TabfilterProps {
|
||||
rows: string | Array<string> | { [name: string]: boolean; };
|
||||
onFilterUpdate: (filteredArray: Array<string>, currentFilters: any[]) => any[] | void;
|
||||
rowClass?: string;
|
||||
initialFilters?: string | Array<string> | { [name: string]: boolean; };
|
||||
}
|
||||
|
||||
export declare class TableFilter extends React.Component<TabfilterProps> {}
|
||||
@@ -11,3 +11,7 @@ const test = (levelDown: AbstractLevelDOWN<any, string>) => {
|
||||
test(new AbstractLevelDOWN('here'));
|
||||
// $ExpectType void
|
||||
test(AbstractLevelDOWN('there'));
|
||||
// $ExpectType void
|
||||
test(new AbstractLevelDOWN<any, string>('here'));
|
||||
// $ExpectType void
|
||||
test(AbstractLevelDOWN<any, string>('there'));
|
||||
|
||||
Vendored
+25
-14
@@ -3,6 +3,7 @@
|
||||
// Definitions by: Meirion Hughes <https://github.com/MeirionHughes>
|
||||
// Daniel Byrne <https://github.com/danwbyrne>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export interface AbstractOptions {
|
||||
readonly [k: string]: any;
|
||||
@@ -21,7 +22,7 @@ export interface AbstractGetOptions extends AbstractOptions {
|
||||
asBuffer?: boolean;
|
||||
}
|
||||
|
||||
export interface AbstractLevelDOWN<K, V> extends AbstractOptions {
|
||||
export interface AbstractLevelDOWN<K = any, V = any> extends AbstractOptions {
|
||||
open(cb: ErrorCallback): void;
|
||||
open(options: AbstractOpenOptions, cb: ErrorCallback): void;
|
||||
|
||||
@@ -38,17 +39,23 @@ export interface AbstractLevelDOWN<K, V> extends AbstractOptions {
|
||||
|
||||
batch(): AbstractChainedBatch<K, V>;
|
||||
batch(array: ReadonlyArray<AbstractBatch<K, V>>, cb: ErrorCallback): AbstractChainedBatch<K, V>;
|
||||
batch(array: ReadonlyArray<AbstractBatch<K, V>>, options: AbstractOptions, cb: ErrorCallback): AbstractChainedBatch<K, V>;
|
||||
batch(
|
||||
array: ReadonlyArray<AbstractBatch<K, V>>,
|
||||
options: AbstractOptions,
|
||||
cb: ErrorCallback,
|
||||
): AbstractChainedBatch<K, V>;
|
||||
|
||||
iterator(options?: AbstractIteratorOptions<K>): AbstractIterator<K, V>;
|
||||
}
|
||||
|
||||
export interface AbstractLevelDOWNConstructor {
|
||||
new (location: string): AbstractLevelDOWN<any, any>;
|
||||
(location: string): AbstractLevelDOWN<any, any>;
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
new <K = any, V = any>(location: string): AbstractLevelDOWN<K, V>;
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
<K = any, V = any>(location: string): AbstractLevelDOWN<K, V>;
|
||||
}
|
||||
|
||||
export interface AbstractIteratorOptions<K> extends AbstractOptions {
|
||||
export interface AbstractIteratorOptions<K = any> extends AbstractOptions {
|
||||
gt?: K;
|
||||
gte?: K;
|
||||
lt?: K;
|
||||
@@ -61,20 +68,20 @@ export interface AbstractIteratorOptions<K> extends AbstractOptions {
|
||||
valueAsBuffer?: boolean;
|
||||
}
|
||||
|
||||
export type AbstractBatch<K, V> = PutBatch<K, V> | DelBatch<K, V>;
|
||||
export type AbstractBatch<K = any, V = any> = PutBatch<K, V> | DelBatch<K, V>;
|
||||
|
||||
export interface PutBatch<K, V> {
|
||||
export interface PutBatch<K = any, V = any> {
|
||||
readonly type: 'put';
|
||||
readonly key: K;
|
||||
readonly value: V;
|
||||
}
|
||||
|
||||
export interface DelBatch<K, V> {
|
||||
export interface DelBatch<K = any, V = any> {
|
||||
readonly type: 'del';
|
||||
readonly key: K;
|
||||
}
|
||||
|
||||
export interface AbstractChainedBatch<K, V> extends AbstractChainedBatchConstructor, AbstractOptions {
|
||||
export interface AbstractChainedBatch<K = any, V = any> extends AbstractOptions {
|
||||
put: (key: K, value: V) => this;
|
||||
del: (key: K) => this;
|
||||
clear: () => this;
|
||||
@@ -83,19 +90,23 @@ export interface AbstractChainedBatch<K, V> extends AbstractChainedBatchConstruc
|
||||
}
|
||||
|
||||
export interface AbstractChainedBatchConstructor {
|
||||
new(db: any): AbstractChainedBatch<any, any>;
|
||||
(db: any): AbstractChainedBatch<any, any>;
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
new <K = any, V = any>(db: any): AbstractChainedBatch<K, V>;
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
<K = any, V = any>(db: any): AbstractChainedBatch<K, V>;
|
||||
}
|
||||
|
||||
export interface AbstractIterator<K, V> extends AbstractChainedBatchConstructor {
|
||||
export interface AbstractIterator<K, V> extends AbstractOptions {
|
||||
db: AbstractLevelDOWN<K, V>;
|
||||
next(cb: ErrorKeyValueCallback<K, V>): this;
|
||||
end(cb: ErrorCallback): void;
|
||||
}
|
||||
|
||||
export interface AbstractIteratorConstructor {
|
||||
new(db: any): AbstractIterator<any, any>;
|
||||
(db: any): AbstractIterator<any, any>;
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
new <K = any, V = any>(db: any): AbstractIterator<K, V>;
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
<K = any, V = any>(db: any): AbstractIterator<K, V>;
|
||||
}
|
||||
|
||||
export const AbstractLevelDOWN: AbstractLevelDOWNConstructor;
|
||||
|
||||
@@ -400,10 +400,10 @@ cognitoUserPoolEvent.request.session![0].challengeName === "DEVICE_SRP_AUTH";
|
||||
cognitoUserPoolEvent.request.session![0].challengeName === "DEVICE_PASSWORD_VERIFIER";
|
||||
cognitoUserPoolEvent.request.session![0].challengeName === "ADMIN_NO_SRP_AUTH";
|
||||
bool = cognitoUserPoolEvent.request.session![0].challengeResult;
|
||||
strOrUndefined = cognitoUserPoolEvent.request.session![0].challengeMetaData;
|
||||
strOrUndefined = cognitoUserPoolEvent.request.session![0].challengeMetadata;
|
||||
strOrUndefined = cognitoUserPoolEvent.request.challengeName;
|
||||
str = cognitoUserPoolEvent.request.privateChallengeParameters!["answer"];
|
||||
str = cognitoUserPoolEvent.request.challengeAnswer!["answer"];
|
||||
str = cognitoUserPoolEvent.request.challengeAnswer!;
|
||||
boolOrUndefined = cognitoUserPoolEvent.response.answerCorrect;
|
||||
strOrUndefined = cognitoUserPoolEvent.response.smsMessage;
|
||||
strOrUndefined = cognitoUserPoolEvent.response.emailMessage;
|
||||
@@ -413,7 +413,7 @@ boolOrUndefined = cognitoUserPoolEvent.response.issueTokens;
|
||||
boolOrUndefined = cognitoUserPoolEvent.response.failAuthentication;
|
||||
str = cognitoUserPoolEvent.response.publicChallengeParameters!["captchaUrl"];
|
||||
str = cognitoUserPoolEvent.response.privateChallengeParameters!["answer"];
|
||||
strOrUndefined = cognitoUserPoolEvent.response.challengeMetaData;
|
||||
strOrUndefined = cognitoUserPoolEvent.response.challengeMetadata;
|
||||
boolOrUndefined = cognitoUserPoolEvent.response.answerCorrect;
|
||||
|
||||
// CloudFormation Custom Resource
|
||||
@@ -581,7 +581,7 @@ const CodePipelineEvent: AWSLambda.CodePipelineEvent = {
|
||||
CodePipelineEvent["CodePipeline.job"].data.encryptionKey = { type: 'KMS', id: 'key' };
|
||||
|
||||
/* CloudFront events, see http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html */
|
||||
const CloudFrontRequestEvent: AWSLambda.CloudFrontRequestEvent = {
|
||||
const CloudFrontRequestWithCustomOriginEvent: AWSLambda.CloudFrontRequestEvent = {
|
||||
Records: [
|
||||
{
|
||||
cf: {
|
||||
@@ -630,7 +630,44 @@ const CloudFrontRequestEvent: AWSLambda.CloudFrontRequestEvent = {
|
||||
"TLSv1",
|
||||
"TLSv1.1"
|
||||
]
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const CloudFrontRequestWithS3OriginEvent: AWSLambda.CloudFrontRequestEvent = {
|
||||
Records: [
|
||||
{
|
||||
cf: {
|
||||
config: {
|
||||
distributionDomainName: "d123.cloudfront.net",
|
||||
distributionId: "EDFDVBD6EXAMPLE",
|
||||
eventType: "viewer-request",
|
||||
requestId: "MRVMF7KydIvxMWfJIglgwHQwZsbG2IhRJ07sn9AkKUFSHS9EXAMPLE=="
|
||||
},
|
||||
request: {
|
||||
clientIp: "2001:0db8:85a3:0:0:8a2e:0370:7334",
|
||||
method: "GET",
|
||||
uri: "/picture.jpg",
|
||||
querystring: "size=large",
|
||||
headers: {
|
||||
host: [
|
||||
{
|
||||
key: "Host",
|
||||
value: "d111111abcdef8.cloudfront.net"
|
||||
}
|
||||
],
|
||||
"user-agent": [
|
||||
{
|
||||
key: "User-Agent",
|
||||
value: "curl/7.51.0"
|
||||
}
|
||||
]
|
||||
},
|
||||
origin: {
|
||||
s3: {
|
||||
authMethod: "origin-access-identity",
|
||||
customHeaders: {
|
||||
@@ -812,6 +849,56 @@ apiGtwProxyHandler = proxyHandler;
|
||||
const codePipelineHandler: AWSLambda.CodePipelineHandler = (event: AWSLambda.CodePipelineEvent, context: AWSLambda.Context, cb: AWSLambda.Callback<void>) => {};
|
||||
|
||||
const cloudFrontRequestHandler: AWSLambda.CloudFrontRequestHandler = (event: AWSLambda.CloudFrontRequestEvent, context: AWSLambda.Context, cb: AWSLambda.CloudFrontRequestCallback) => {
|
||||
event = CloudFrontRequestWithCustomOriginEvent;
|
||||
// $ExpectType CloudFrontRequestEvent
|
||||
event;
|
||||
let request = event.Records[0].cf.request;
|
||||
|
||||
let s3Origin: AWSLambda.CloudFrontS3Origin = {
|
||||
authMethod: 'none',
|
||||
customHeaders: {},
|
||||
domainName: 'example.com',
|
||||
path: '/',
|
||||
region: 'us-east-1'
|
||||
};
|
||||
|
||||
if (request.origin && request.origin.custom) {
|
||||
request.origin.custom.domainName;
|
||||
request.origin.custom.domainName = "example2.com";
|
||||
|
||||
// $ExpectError
|
||||
s3Origin = request.origin.s3;
|
||||
|
||||
// $ExpectError
|
||||
request.origin.s3.path = '/';
|
||||
}
|
||||
|
||||
let customOrigin: AWSLambda.CloudFrontCustomOrigin = {
|
||||
customHeaders: {},
|
||||
domainName: 'example.com',
|
||||
keepaliveTimeout: 60,
|
||||
path: '/',
|
||||
port: 80,
|
||||
protocol: 'http',
|
||||
readTimeout: 30,
|
||||
sslProtocols: []
|
||||
};
|
||||
|
||||
event = CloudFrontRequestWithS3OriginEvent;
|
||||
// $ExpectType CloudFrontRequestEvent
|
||||
event;
|
||||
request = event.Records[0].cf.request;
|
||||
if (request.origin && request.origin.s3) {
|
||||
request.origin.s3.path;
|
||||
request.origin.s3.path = "/new_path";
|
||||
|
||||
// $ExpectError
|
||||
customOrigin = request.origin.custom;
|
||||
|
||||
// $ExpectError
|
||||
request.origin.custom.path = '/';
|
||||
}
|
||||
|
||||
cb();
|
||||
cb(null);
|
||||
cb(new Error(''));
|
||||
|
||||
Vendored
+31
-3
@@ -21,6 +21,7 @@
|
||||
// Jeremy Nagel <https://github.com/jeznag>
|
||||
// Louis Larry <https://github.com/louislarry>
|
||||
// Daniel Papukchiev <https://github.com/dpapukchiev>
|
||||
// Oliver Hookins <https://github.com/ohookins>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -250,11 +251,11 @@ export interface CognitoUserPoolTriggerEvent {
|
||||
session?: Array<{
|
||||
challengeName: "CUSTOM_CHALLENGE" | "PASSWORD_VERIFIER" | "SMS_MFA" | "DEVICE_SRP_AUTH" | "DEVICE_PASSWORD_VERIFIER" | "ADMIN_NO_SRP_AUTH";
|
||||
challengeResult: boolean;
|
||||
challengeMetaData?: string;
|
||||
challengeMetadata?: string;
|
||||
}>;
|
||||
challengeName?: string;
|
||||
privateChallengeParameters?: { [key: string]: string };
|
||||
challengeAnswer?: { [key: string]: string };
|
||||
challengeAnswer?: string;
|
||||
};
|
||||
response: {
|
||||
autoConfirmUser?: boolean;
|
||||
@@ -266,7 +267,7 @@ export interface CognitoUserPoolTriggerEvent {
|
||||
failAuthentication?: boolean;
|
||||
publicChallengeParameters?: { [key: string]: string };
|
||||
privateChallengeParameters?: { [key: string]: string };
|
||||
challengeMetaData?: string;
|
||||
challengeMetadata?: string;
|
||||
answerCorrect?: boolean;
|
||||
};
|
||||
}
|
||||
@@ -561,6 +562,9 @@ export interface CodePipelineEvent {
|
||||
/**
|
||||
* CloudFront events
|
||||
* http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html
|
||||
* Bear in mind that the "example" event structure in the page above includes
|
||||
* both an S3 and a Custom origin, which is not strictly allowed. Only one
|
||||
* of these per event may be present.
|
||||
*/
|
||||
export interface CloudFrontHeaders {
|
||||
[name: string]: Array<{
|
||||
@@ -569,6 +573,29 @@ export interface CloudFrontHeaders {
|
||||
}>;
|
||||
}
|
||||
|
||||
export type CloudFrontOrigin =
|
||||
| { s3: CloudFrontS3Origin, custom?: never }
|
||||
| { custom: CloudFrontCustomOrigin, s3?: never };
|
||||
|
||||
export interface CloudFrontCustomOrigin {
|
||||
customHeaders: CloudFrontHeaders;
|
||||
domainName: string;
|
||||
keepaliveTimeout: number;
|
||||
path: string;
|
||||
port: number;
|
||||
protocol: 'http' | 'https';
|
||||
readTimeout: number;
|
||||
sslProtocols: string[];
|
||||
}
|
||||
|
||||
export interface CloudFrontS3Origin {
|
||||
authMethod: 'origin-access-identity' | 'none';
|
||||
customHeaders: CloudFrontHeaders;
|
||||
domainName: string;
|
||||
path: string;
|
||||
region: string;
|
||||
}
|
||||
|
||||
export interface CloudFrontResponse {
|
||||
status: string;
|
||||
statusDescription: string;
|
||||
@@ -581,6 +608,7 @@ export interface CloudFrontRequest {
|
||||
uri: string;
|
||||
querystring: string;
|
||||
headers: CloudFrontHeaders;
|
||||
origin?: CloudFrontOrigin;
|
||||
}
|
||||
|
||||
export interface CloudFrontEvent {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { fromBase58 } from 'bip32';
|
||||
|
||||
const node = fromBase58("xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi");
|
||||
|
||||
const child = node.derivePath('m/0');
|
||||
|
||||
const grandchild = child.derive(2);
|
||||
|
||||
grandchild.toWIF() === 'Kxtby4wzfHeCaRXma16dBNLgUE7Ct3Xkb6sRs3aZ56Bmtf1rcNWs';
|
||||
Vendored
+67
@@ -0,0 +1,67 @@
|
||||
// Type definitions for bip32 1.0
|
||||
// Project: https://github.com/bitcoinjs/bip32#readme
|
||||
// Definitions by: My Self <https://github.com/me>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface NetworkType {
|
||||
wif: number; // UInt8
|
||||
bip32: {
|
||||
public: number; // UInt32
|
||||
private: number; // UInt32
|
||||
};
|
||||
}
|
||||
|
||||
export class BIP32 {
|
||||
private constructor(d: Buffer, Q: Buffer, chainCode: Buffer, network: NetworkType);
|
||||
|
||||
identifier: Buffer;
|
||||
fingerprint: Buffer;
|
||||
privateKey: Buffer;
|
||||
publicKey: Buffer;
|
||||
|
||||
private depth: number;
|
||||
private index: number;
|
||||
private parentFingerprint: number;
|
||||
private network: NetworkType;
|
||||
|
||||
isNeutered(): boolean;
|
||||
neutered(): BIP32;
|
||||
toBase58(): string;
|
||||
toWIF(): string;
|
||||
derive(index: number): BIP32;
|
||||
deriveHardened(index: number): BIP32;
|
||||
derivePath(path: string): BIP32;
|
||||
sign(hash: Buffer): Buffer;
|
||||
verify(hash: Buffer, signature: Buffer): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a node
|
||||
* @param string base58 encoded string
|
||||
* @param network network type of the node
|
||||
*/
|
||||
export function fromBase58(string: string, network?: NetworkType): BIP32;
|
||||
|
||||
/**
|
||||
* Returns a hardened node
|
||||
* @param privateKey node private key
|
||||
* @param chainCode 256-bits entropy extension
|
||||
* @param network network type of the node
|
||||
*/
|
||||
export function fromPrivateKey(privateKey: Buffer, chainCode: Buffer, network?: NetworkType): BIP32;
|
||||
|
||||
/**
|
||||
* Returns a non-hardened node
|
||||
* @param publicKey node public key
|
||||
* @param chainCode 256-bits entropy extension
|
||||
* @param network network type of the node
|
||||
*/
|
||||
export function fromPublicKey(publicKey: Buffer, chainCode: Buffer, network?: NetworkType): BIP32;
|
||||
|
||||
/**
|
||||
* Returns a hardened node
|
||||
* @param seed seed encoding node info
|
||||
* @param network network type of the node
|
||||
*/
|
||||
export function fromSeed(seed: Buffer, network?: NetworkType): BIP32;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"bip32-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,4 +1,3 @@
|
||||
import bigi = require('bigi');
|
||||
import bitcoin = require('bitcoinjs-lib');
|
||||
|
||||
// For testing only
|
||||
@@ -8,19 +7,18 @@ function rng() {
|
||||
|
||||
// Generate a random bitcoin address
|
||||
const keyPair1 = bitcoin.ECPair.makeRandom({rng});
|
||||
const address = keyPair1.getAddress();
|
||||
const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair1.publicKey });
|
||||
keyPair1.toWIF();
|
||||
|
||||
// Generate an address from a SHA256 hash
|
||||
const hash = bitcoin.crypto.sha256(Buffer.from('correct horse battery staple', 'utf8'));
|
||||
const d = bigi.fromBuffer(hash);
|
||||
const keyPair2 = new bitcoin.ECPair(d);
|
||||
const keyPair2 = bitcoin.ECPair.fromPrivateKey(hash);
|
||||
|
||||
// Generate a random keypair for alternative networks
|
||||
const keyPair3 = bitcoin.ECPair.makeRandom({network: bitcoin.networks.litecoin, rng});
|
||||
const keyPair3 = bitcoin.ECPair.makeRandom({network: bitcoin.networks.testnet, rng});
|
||||
keyPair3.toWIF();
|
||||
keyPair3.getAddress();
|
||||
const network = keyPair3.getNetwork();
|
||||
bitcoin.payments.p2pkh({ pubkey: keyPair3.publicKey });
|
||||
const network = keyPair3.network;
|
||||
|
||||
// Test TransactionBuilder and Transaction
|
||||
const txb = new bitcoin.TransactionBuilder();
|
||||
@@ -41,22 +39,3 @@ bitcoin.address.toBase58Check(rsBase58Check.hash, rsBase58Check.version);
|
||||
bitcoin.address.toBech32(rsBech32.data, rsBech32.version, rsBech32.prefix);
|
||||
bitcoin.address.toOutputScript(address);
|
||||
bitcoin.address.toOutputScript(address, network);
|
||||
|
||||
const redeemScript = bitcoin.script.multisig.output.encode(
|
||||
2,
|
||||
[
|
||||
new Buffer('12345678901234567890123456789012'),
|
||||
new Buffer('12345678901234567890123456789012'),
|
||||
new Buffer('12345678901234567890123456789012'),
|
||||
]
|
||||
);
|
||||
bitcoin.script.scriptHash.input.encode(
|
||||
bitcoin.script.multisig.input.encodeStack(
|
||||
[
|
||||
new Buffer('12345678901234567890123456789012'),
|
||||
new Buffer('12345678901234567890123456789012'),
|
||||
],
|
||||
redeemScript,
|
||||
),
|
||||
redeemScript,
|
||||
);
|
||||
|
||||
Vendored
+48
-138
@@ -1,4 +1,4 @@
|
||||
// Type definitions for bitcoinjs-lib 3.4
|
||||
// Type definitions for bitcoinjs-lib 4.0
|
||||
// Project: https://github.com/bitcoinjs/bitcoinjs-lib
|
||||
// Definitions by: Mohamed Hegazy <https://github.com/mhegazy>
|
||||
// Daniel <https://github.com/dlebrecht>
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import BigInteger = require('bigi');
|
||||
|
||||
export interface Out {
|
||||
script: Buffer;
|
||||
value: number;
|
||||
@@ -68,29 +66,23 @@ export class Block {
|
||||
}
|
||||
|
||||
export class ECPair {
|
||||
constructor(d: BigInteger, Q?: null, options?: { compressed?: boolean, network?: Network });
|
||||
|
||||
constructor(d: null | undefined, Q: any, options?: { compressed?: boolean, network?: Network }); // Q should be ECPoint, but not sure how to define such type
|
||||
|
||||
d: BigInteger;
|
||||
|
||||
readonly compressed: boolean;
|
||||
|
||||
readonly privateKey: Buffer;
|
||||
|
||||
readonly publicKey: Buffer;
|
||||
|
||||
readonly network: Network;
|
||||
|
||||
getAddress(): string;
|
||||
|
||||
getNetwork(): Network;
|
||||
|
||||
getPublicKeyBuffer(): Buffer;
|
||||
|
||||
sign(hash: Buffer): ECSignature;
|
||||
sign(hash: Buffer): Buffer;
|
||||
|
||||
toWIF(): string;
|
||||
|
||||
verify(hash: Buffer, signature: ECSignature): boolean;
|
||||
verify(hash: Buffer, signature: Buffer): boolean;
|
||||
|
||||
static fromPublicKeyBuffer(buffer: Buffer, network: Network): ECPair;
|
||||
static fromPrivateKey(buffer: Buffer, options?: { compressed?: boolean, network?: Network }): ECPair;
|
||||
|
||||
static fromPublicKey(buffer: Buffer, options?: { compressed?: boolean, network?: Network }): ECPair;
|
||||
|
||||
static fromWIF(string: string, network?: Network): ECPair;
|
||||
|
||||
@@ -99,66 +91,6 @@ export class ECPair {
|
||||
|
||||
export type Rng = (size: number) => Buffer;
|
||||
|
||||
export class ECSignature {
|
||||
constructor(r: BigInteger, s: BigInteger);
|
||||
|
||||
toCompact(i: number, compressed: boolean): Buffer;
|
||||
|
||||
toDER(): Buffer;
|
||||
|
||||
toScriptSignature(hashType: number): Buffer;
|
||||
|
||||
static fromDER(buffer: Buffer): ECSignature;
|
||||
|
||||
static parseCompact(buffer: Buffer): { compressed: boolean, i: number, signature: ECSignature };
|
||||
|
||||
static parseScriptSignature(buffer: Buffer): { signature: ECSignature, hashType: number };
|
||||
}
|
||||
|
||||
export class HDNode {
|
||||
constructor(keyPair: ECPair, chainCode: Buffer);
|
||||
|
||||
keyPair: ECPair;
|
||||
|
||||
derive(index: number): HDNode;
|
||||
|
||||
deriveHardened(index: number): HDNode;
|
||||
|
||||
derivePath(path: string): HDNode;
|
||||
|
||||
getAddress(): string;
|
||||
|
||||
getFingerprint(): Buffer;
|
||||
|
||||
getIdentifier(): Buffer;
|
||||
|
||||
getNetwork(): Network;
|
||||
|
||||
getPublicKeyBuffer(): Buffer;
|
||||
|
||||
isNeutered(): boolean;
|
||||
|
||||
neutered(): HDNode;
|
||||
|
||||
sign(hash: Buffer): ECSignature;
|
||||
|
||||
toBase58(): string;
|
||||
|
||||
verify(hash: Buffer, signature: ECSignature): boolean;
|
||||
|
||||
static HIGHEST_BIT: number;
|
||||
|
||||
static LENGTH: number;
|
||||
|
||||
static fromBase58(string: string, networks?: Network[] | Network): HDNode;
|
||||
|
||||
static fromSeedBuffer(seed: Buffer, network?: Network): HDNode;
|
||||
|
||||
static fromSeedHex(hex: string, network?: Network): HDNode;
|
||||
|
||||
static MASTER_SECRET: Buffer;
|
||||
}
|
||||
|
||||
export class Transaction {
|
||||
version: number;
|
||||
locktime: number;
|
||||
@@ -236,9 +168,6 @@ export interface Input {
|
||||
}
|
||||
|
||||
export class TransactionBuilder {
|
||||
tx: Transaction;
|
||||
inputs: Input[];
|
||||
|
||||
constructor(network?: Network, maximumFeeRate?: number);
|
||||
|
||||
addInput(txhash: Buffer | string | Transaction, vout: number, sequence?: number, prevOutScript?: Buffer): number;
|
||||
@@ -261,7 +190,6 @@ export class TransactionBuilder {
|
||||
|
||||
export const networks: {
|
||||
bitcoin: Network;
|
||||
litecoin: Network;
|
||||
testnet: Network;
|
||||
};
|
||||
|
||||
@@ -391,7 +319,7 @@ export namespace address {
|
||||
/** @since 3.2.0 */
|
||||
function fromBech32(address: string): { data: Buffer, prefix: string, version: number };
|
||||
|
||||
function fromOutputScript(outputScript: Buffer, network?: Network): string;
|
||||
function fromOutputScript(output: Buffer, network?: Network): string;
|
||||
|
||||
function toBase58Check(hash: Buffer, version: number): string;
|
||||
|
||||
@@ -401,26 +329,6 @@ export namespace address {
|
||||
function toOutputScript(address: string, network?: Network): Buffer;
|
||||
}
|
||||
|
||||
export namespace bufferutils {
|
||||
function pushDataSize(i: number): number;
|
||||
|
||||
function readPushDataInt(buffer: Buffer, offset: number): { opcode: number, number: number, size: number };
|
||||
|
||||
function readUInt64LE(buffer: Buffer, offset: number): number;
|
||||
|
||||
function readVarInt(buffer: Buffer, offset: number): { number: number, size: number };
|
||||
|
||||
function varIntBuffer(number: number, buffer: Buffer, offset: number): Buffer;
|
||||
|
||||
function varIntSize(number: number): number;
|
||||
|
||||
function writePushDataInt(buffer: Buffer, number: number, offset: number): number;
|
||||
|
||||
function writeUInt64LE(buffer: Buffer, value: number, offset: number): number;
|
||||
|
||||
function writeVarInt(buffer: Buffer, number: number, offset: number): number;
|
||||
}
|
||||
|
||||
export namespace crypto {
|
||||
function hash160(buffer: Buffer): Buffer;
|
||||
|
||||
@@ -449,7 +357,7 @@ export namespace script {
|
||||
|
||||
function isCanonicalPubKey(buffer: Buffer): boolean;
|
||||
|
||||
function isCanonicalSignature(buffer: Buffer): boolean;
|
||||
function isCanonicalScriptSignature(buffer: Buffer): boolean;
|
||||
|
||||
function isDefinedHashType(hashType: any): boolean;
|
||||
|
||||
@@ -465,66 +373,48 @@ export namespace script {
|
||||
function encode(number: number): Buffer;
|
||||
}
|
||||
|
||||
namespace signature {
|
||||
function decode(buffer: Buffer): { signature: Buffer, hashType: number };
|
||||
|
||||
function encode(signature: Buffer, hashType: number): Buffer;
|
||||
}
|
||||
|
||||
const multisig: {
|
||||
input: {
|
||||
check(script: Buffer, allowIncomplete: boolean): boolean;
|
||||
decode(buffer: Buffer): Array<Buffer | number>;
|
||||
decodeStack(stack: Buffer[], allowIncomplete: boolean): Array<Buffer | number>;
|
||||
encode(signatures: Buffer[], scriptPubKey: Buffer): Buffer;
|
||||
encodeStack(signatures: Buffer[], scriptPubKey: Buffer): Buffer[];
|
||||
};
|
||||
output: {
|
||||
check(script: Buffer, allowIncomplete: boolean): boolean;
|
||||
decode(buffer: Buffer, allowIncomplete: boolean): { m: number; pubKeys: Array<Buffer | number> };
|
||||
encode(m: number, pubKeys: Array<Buffer | number>): Buffer;
|
||||
};
|
||||
};
|
||||
|
||||
const pubKey: {
|
||||
input: {
|
||||
check(script: Buffer): boolean;
|
||||
decode(buffer: Buffer): Array<Buffer | number>;
|
||||
decodeStack(stack: Buffer[]): Array<Buffer | number>;
|
||||
encode(signature: Buffer): Buffer;
|
||||
encodeStack(signature: Buffer): Buffer[];
|
||||
};
|
||||
|
||||
output: {
|
||||
check(script: Buffer): boolean;
|
||||
decode(buffer: Buffer): Buffer | number;
|
||||
encode(pubKey: Buffer): Buffer;
|
||||
};
|
||||
};
|
||||
|
||||
const pubKeyHash: {
|
||||
input: {
|
||||
check(script: Buffer): boolean;
|
||||
decode(buffer: Buffer): { signature: Buffer; pubKey: Buffer };
|
||||
decodeStack(stack: Buffer[]): { signature: Buffer; pubKey: Buffer };
|
||||
encode(signature: Buffer, pubKey: Buffer): Buffer;
|
||||
encodeStack(signature: Buffer, pubKey: Buffer): [Buffer, Buffer];
|
||||
};
|
||||
|
||||
output: {
|
||||
check(script: Buffer): boolean;
|
||||
decode(buffer: Buffer): Buffer;
|
||||
encode(pubKeyHash: Buffer): Buffer;
|
||||
};
|
||||
};
|
||||
|
||||
const scriptHash: {
|
||||
input: {
|
||||
check(script: Buffer, allowIncomplete: boolean): boolean;
|
||||
decode(buffer: Buffer): { redeemScriptStack: Buffer[]; redeemScript: Buffer };
|
||||
decodeStack(stack: Buffer[]): { redeemScriptStack: Buffer[]; redeemScript: Buffer };
|
||||
encode(redeemScriptSig: Array<Buffer | number>, redeemScript: Buffer): Buffer;
|
||||
encodeStack(redeemScriptStack: Buffer[], redeemScript: Buffer): Buffer[];
|
||||
};
|
||||
|
||||
output: {
|
||||
check(script: Buffer): boolean;
|
||||
decode(buffer: Buffer): Buffer;
|
||||
encode(scriptHash: Buffer): Buffer;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -539,36 +429,56 @@ export namespace script {
|
||||
const witnessPubKeyHash: {
|
||||
input: {
|
||||
check(script: Buffer): boolean;
|
||||
decodeStack(stack: Buffer[]): { signature: Buffer; pubKey: Buffer };
|
||||
encodeStack(signature: Buffer, pubKey: Buffer): [Buffer, Buffer];
|
||||
};
|
||||
|
||||
output: {
|
||||
check(script: Buffer): boolean;
|
||||
decode(buffer: Buffer): Buffer;
|
||||
encode(pubKeyHash: Buffer): Buffer;
|
||||
};
|
||||
};
|
||||
|
||||
const witnessScriptHash: {
|
||||
input: {
|
||||
check(script: Buffer, allowIncomplete: boolean): boolean;
|
||||
decodeStack(stack: Buffer[]): { redeemScriptStack: Buffer[]; redeemScript: Buffer };
|
||||
encodeStack(redeemScriptStack: Buffer[], redeemScript: Buffer): Buffer[];
|
||||
};
|
||||
|
||||
output: {
|
||||
check(script: Buffer): boolean;
|
||||
decode(buffer: Buffer): Buffer;
|
||||
encode(scriptHash: Buffer): Buffer;
|
||||
};
|
||||
};
|
||||
|
||||
const nullData: {
|
||||
output: {
|
||||
check(script: Buffer): boolean;
|
||||
decode(buffer: Buffer): Buffer;
|
||||
encode(data: Buffer): Buffer;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export namespace payments {
|
||||
function p2data(a: { network?: Network, output?: Buffer, data?: Buffer[] }, opts?: { validate?: boolean }):
|
||||
{ output: Buffer, data: Buffer[] };
|
||||
|
||||
function p2ms(a: { network?: Network, m?: number, n?: number, output?: Buffer, pubkeys?: Buffer[], signatures?: Buffer[], input?: Buffer }, opts?: { validate?: boolean }):
|
||||
{ output: Buffer, m: number, n: number, pubkeys: Buffer[], signatures: Buffer[], input: Buffer, witness: Buffer[] };
|
||||
|
||||
function p2pk(a: { input?: Buffer, network?: Network, output?: Buffer, pubkey?: Buffer, signature?: Buffer }, opts?: { validate?: boolean }):
|
||||
{ output: Buffer, pubkey: Buffer, signature: Buffer, input: Buffer, witness: Buffer[] };
|
||||
|
||||
function p2pkh(a: { address?: string, hash?: Buffer, input?: Buffer, network?: Network, output?: Buffer, pubkey?: Buffer, signature?: Buffer }, opts?: { validate?: boolean }):
|
||||
{ address: string, hash: Buffer, output: Buffer, pubkey: Buffer, signature: Buffer, input: Buffer, witness: Buffer[] };
|
||||
|
||||
function p2sh(a: { address?: string, hash?: Buffer, input?: Buffer, network?: Network, output?: Buffer, witness?: Buffer[], redeem?: Redeem }, opts?: { validate?: boolean }):
|
||||
{ address: string, hash: Buffer, output: Buffer, redeem: Redeem, input: Buffer, witness: Buffer[] };
|
||||
|
||||
function p2wpkh(a: { address?: string, hash?: Buffer, input?: Buffer, network?: Network, output?: Buffer, pubkey?: Buffer, signature?: Buffer, witness?: Buffer[] },
|
||||
opts?: { validate?: boolean }): { address: string, hash: Buffer, output: Buffer, pubkey: Buffer, signature: Buffer, input: Buffer, witness: Buffer[] };
|
||||
|
||||
function p2wsh(a: { address?: string, hash?: Buffer, input?: Buffer, network?: Network, output?: Buffer, witness?: Buffer[], redeem?: Redeem }, opts?: { validate?: boolean }):
|
||||
{ address: string, hash: Buffer, output: Buffer, redeem: Redeem, input: Buffer, witness: Buffer[] };
|
||||
|
||||
class Redeem {
|
||||
input?: Buffer;
|
||||
network?: Network;
|
||||
output?: Buffer;
|
||||
witness?: Buffer[];
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+6
-1
@@ -15,7 +15,7 @@ declare namespace CookieSessionInterfaces {
|
||||
/**
|
||||
* The name of the cookie to set, defaults to session.
|
||||
*/
|
||||
name: string;
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* The list of keys to use to sign & verify cookie values. Set cookies are always signed with keys[0], while the other keys are valid for verification, allowing for key rotation.
|
||||
@@ -47,6 +47,11 @@ declare namespace CookieSessionInterfaces {
|
||||
*/
|
||||
domain?: string;
|
||||
|
||||
/**
|
||||
* a boolean or string indicating whether the cookie is a "same site" cookie (false by default). This can be set to 'strict', 'lax', or true (which maps to 'strict').
|
||||
*/
|
||||
sameSite?: "strict" | "lax" | boolean;
|
||||
|
||||
/**
|
||||
* a boolean indicating whether the cookie is only to be sent over HTTPS (false by default for HTTP, true by default for HTTPS).
|
||||
*/
|
||||
|
||||
@@ -105,15 +105,7 @@ declare const wrongPromise: Promise<number>;
|
||||
</PromiseSubscription>;
|
||||
|
||||
// $ExpectError
|
||||
const MismatchSubscription = createSubscription({
|
||||
getCurrentValue: (a: number) => null,
|
||||
subscribe: (a: string, callback) => (() => undefined)
|
||||
});
|
||||
const MismatchSubscription = createSubscription({ getCurrentValue: (a: number) => null, subscribe: (a: string, callback) => (() => undefined) });
|
||||
|
||||
// $ExpectError
|
||||
const NoUnsubscribe = createSubscription({
|
||||
getCurrentValue: (a: number) => a,
|
||||
subscribe: (a: number, callback) => {
|
||||
// oops, should've returned a callback here
|
||||
}
|
||||
});
|
||||
const NoUnsubscribe = createSubscription({ getCurrentValue: (a: number) => a, subscribe: (a: number, callback) => { /* oops, should've returned a callback here */ }});
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"d3.cloud.layout-tests.ts"
|
||||
"d3-cloud-tests.ts"
|
||||
]
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import Ember from 'ember';
|
||||
/**
|
||||
* Ember.Object.extend(...) accepts any number of mixins or literals.
|
||||
*/
|
||||
declare type MixinOrLiteral<T, Base> = Ember.Mixin<T, Base> | T;
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Used to infer the type of ember classes of type `T`.
|
||||
*
|
||||
* Generally you would use `EmberClass.create()` instead of `new EmberClass()`.
|
||||
*
|
||||
* The single-arg constructor is required by the typescript compiler.
|
||||
* The multi-arg constructor is included for better ergonomics.
|
||||
*
|
||||
* Implementation is carefully chosen for the reasons described in
|
||||
* https://github.com/typed-ember/ember-typings/pull/29
|
||||
*/
|
||||
export type EmberClassConstructor<T> = (new (properties?: object) => T) & (new (...args: any[]) => T);
|
||||
|
||||
/**
|
||||
* Check that any arguments to `create()` match the type's properties.
|
||||
*
|
||||
* Accept any additional properties and add merge them into the instance.
|
||||
*/
|
||||
export type EmberInstanceArguments<T> = Partial<T> & {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
/**
|
||||
* Accept any additional properties and add merge them into the prototype.
|
||||
*/
|
||||
export interface EmberClassArguments {
|
||||
[key: string]: any;
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import ComputedProperty from '@ember/object/computed';
|
||||
/**
|
||||
* Deconstructs computed properties into the types which would be returned by `.get()`.
|
||||
*/
|
||||
export type UnwrapComputedPropertyGetter<T> =
|
||||
T extends ComputedProperty<infer U, any> ? U :
|
||||
T;
|
||||
export type UnwrapComputedPropertyGetters<T> = {
|
||||
[P in keyof T]: UnwrapComputedPropertyGetter<T[P]>;
|
||||
};
|
||||
|
||||
export type UnwrapComputedPropertySetter<T> =
|
||||
T extends ComputedProperty<any, infer V> ? V :
|
||||
T;
|
||||
export type UnwrapComputedPropertySetters<T> = {
|
||||
[P in keyof T]: UnwrapComputedPropertySetter<T[P]>;
|
||||
};
|
||||
|
||||
export type ComputedPropertyGetterFunction<T> = (this: any, key: string) => T;
|
||||
export type ComputedPropertySetterFunction<T> = (this: any, key: string, newVal: T, oldVal: T) => T;
|
||||
|
||||
export interface ComputedPropertyGetterObj<T> {
|
||||
get(this: any, key: string): T;
|
||||
}
|
||||
|
||||
export interface ComputedPropertySetterObj<T> {
|
||||
set(this: any, key: string, value: T): T;
|
||||
}
|
||||
export type ComputedPropertyObj<T> = ComputedPropertyGetterObj<T> | ComputedPropertySetterObj<T> | (ComputedPropertyGetterObj<T> & ComputedPropertySetterObj<T>);
|
||||
|
||||
export type ComputedPropertyGetter<T> = ComputedPropertyGetterFunction<T> | ComputedPropertyGetterObj<T>;
|
||||
export type ComputedPropertySetter<T> = ComputedPropertySetterFunction<T> | ComputedPropertySetterObj<T>;
|
||||
|
||||
export type ComputedPropertyCallback<T> = ComputedPropertyGetterFunction<T> | ComputedPropertyObj<T>;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import { Ember } from "ember";
|
||||
|
||||
/**
|
||||
* Map type `T` to a plain object hash with the identity mapping.
|
||||
*
|
||||
* Discards any additional object identity like the ability to `new()` up the class.
|
||||
* The `new()` capability is added back later by merging `EmberClassConstructor<T>`
|
||||
*
|
||||
* Implementation is carefully chosen for the reasons described in
|
||||
* https://github.com/typed-ember/ember-typings/pull/29
|
||||
*/
|
||||
export type Objectify<T> = Readonly<T>;
|
||||
export type ExtractPropertyNamesOfType<T, S> = {
|
||||
[K in keyof T]: T[K] extends S ? K : never
|
||||
}[keyof T];
|
||||
export type Fix<T> = { [K in keyof T]: T[K] };
|
||||
|
||||
export type KeysOfType<Base, Condition> = keyof Pick<Base, {
|
||||
[Key in keyof Base]: Base[Key] extends Condition ? Key : never
|
||||
}[keyof Base]>;
|
||||
|
||||
export interface TypeLookup {
|
||||
string: string;
|
||||
number: number;
|
||||
boolean: boolean;
|
||||
regexp: RegExp;
|
||||
function: (...args: any[]) => any;
|
||||
array: any[];
|
||||
error: Error;
|
||||
filelist: FileList;
|
||||
class: typeof Ember.Object;
|
||||
instance: Ember.Object;
|
||||
date: Date;
|
||||
null: null;
|
||||
undefined: undefined;
|
||||
}
|
||||
Vendored
+57
-69
@@ -16,6 +16,16 @@
|
||||
/// <reference types="handlebars" />
|
||||
|
||||
declare module 'ember' {
|
||||
import {
|
||||
UnwrapComputedPropertySetters,
|
||||
UnwrapComputedPropertySetter,
|
||||
UnwrapComputedPropertyGetters,
|
||||
UnwrapComputedPropertyGetter,
|
||||
ComputedPropertyCallback
|
||||
} from 'ember/-private-types/object/computed';
|
||||
import { Objectify, Fix, KeysOfType, TypeLookup } from 'ember/-private-types/utils';
|
||||
import { EmberClassArguments, EmberClassConstructor, EmberInstanceArguments } from 'ember/-private-types/object';
|
||||
|
||||
// Capitalization is intentional: this makes it much easier to re-export RSVP on
|
||||
// the Ember namespace.
|
||||
import Rsvp from 'rsvp';
|
||||
@@ -28,51 +38,25 @@ declare module 'ember' {
|
||||
// Get an alias to the global Array type to use in inner scope below.
|
||||
type GlobalArray<T> = T[];
|
||||
|
||||
/**
|
||||
* Deconstructs computed properties into the types which would be returned by `.get()`.
|
||||
*/
|
||||
type UnwrapComputedPropertyGetter<T> =
|
||||
T extends Ember.ComputedProperty<infer U, any> ? U :
|
||||
T;
|
||||
type UnwrapComputedPropertyGetters<T> = {
|
||||
[P in keyof T]: UnwrapComputedPropertyGetter<T[P]>;
|
||||
};
|
||||
// TODO: TypeScript 3.0
|
||||
// type FunctionArgs<F extends (...args: any[]) => any> = F extends (...args: infer ARGS) => any ? ARGS : never;
|
||||
type FunctionArgs<F> =
|
||||
F extends (a: infer A) => any
|
||||
? [A]
|
||||
: F extends (a: infer A, b: infer B) => any
|
||||
? [A, B]
|
||||
: F extends (a: infer A, b: infer B, c: infer C) => any
|
||||
? [A, B, C]
|
||||
: F extends (a: infer A, b: infer B, c: infer C, d: infer D) => any
|
||||
? [A, B, C, D]
|
||||
: F extends (a: infer A, b: infer B, c: infer C, d: infer D, e: infer E) => any
|
||||
? [A, B, C, D, E]
|
||||
: never;
|
||||
|
||||
type UnwrapComputedPropertySetter<T> =
|
||||
T extends Ember.ComputedProperty<any, infer U> ? U :
|
||||
T;
|
||||
type UnwrapComputedPropertySetters<T> = {
|
||||
[P in keyof T]: UnwrapComputedPropertySetter<T[P]>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check that any arguments to `create()` match the type's properties.
|
||||
*
|
||||
* Accept any additional properties and add merge them into the instance.
|
||||
*/
|
||||
type EmberInstanceArguments<T> = Partial<T> & {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
/**
|
||||
* Accept any additional properties and add merge them into the prototype.
|
||||
*/
|
||||
interface EmberClassArguments {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map type `T` to a plain object hash with the identity mapping.
|
||||
*
|
||||
* Discards any additional object identity like the ability to `new()` up the class.
|
||||
* The `new()` capability is added back later by merging `EmberClassConstructor<T>`
|
||||
*
|
||||
* Implementation is carefully chosen for the reasons described in
|
||||
* https://github.com/typed-ember/ember-typings/pull/29
|
||||
*/
|
||||
type Objectify<T> = Readonly<T>;
|
||||
|
||||
type Fix<T> = { [K in keyof T]: T[K] };
|
||||
type Mix<A, B> = B & Pick<A, Exclude<keyof A, keyof B>>;
|
||||
type Mix3<A, B, C> = Mix<Mix<A, B>, C>;
|
||||
type Mix4<A, B, C, D> = Mix3<Mix<A, B>, C, D>;
|
||||
type Mix5<A, B, C, D, E> = Mix4<Mix<A, B>, C, D, E>;
|
||||
|
||||
/**
|
||||
* Ember.Object.extend(...) accepts any number of mixins or literals.
|
||||
@@ -90,23 +74,6 @@ declare module 'ember' {
|
||||
* Implementation is carefully chosen for the reasons described in
|
||||
* https://github.com/typed-ember/ember-typings/pull/29
|
||||
*/
|
||||
type EmberClassConstructor<T> = (new (properties?: object) => T) & (new (...args: any[]) => T);
|
||||
|
||||
type ComputedPropertyGetterFunction<T> = (this: any, key: string) => T;
|
||||
|
||||
interface ComputedPropertyGet<T> {
|
||||
get(this: any, key: string): T;
|
||||
}
|
||||
|
||||
interface ComputedPropertySet<T> {
|
||||
set(this: any, key: string, value: T): T;
|
||||
}
|
||||
|
||||
type ComputedPropertyCallback<T> =
|
||||
| ComputedPropertyGetterFunction<T>
|
||||
| ComputedPropertyGet<T>
|
||||
| ComputedPropertySet<T>
|
||||
| (ComputedPropertyGet<T> & ComputedPropertySet<T>);
|
||||
|
||||
interface ActionsHash {
|
||||
[index: string]: (...params: any[]) => any;
|
||||
@@ -129,7 +96,7 @@ declare module 'ember' {
|
||||
|
||||
type ObserverMethod<Target, Sender> =
|
||||
| (keyof Target)
|
||||
| ((this: Target, sender: Sender, key: keyof Sender, value: any, rev: number) => void);
|
||||
| ((this: Target, sender: Sender, key: string, value: any, rev: number) => void);
|
||||
|
||||
interface RenderOptions {
|
||||
into?: string;
|
||||
@@ -310,6 +277,17 @@ declare module 'ember' {
|
||||
|
||||
interface ArrayPrototypeExtensions<T> extends MutableArray<T>, Observable, Copyable {}
|
||||
|
||||
interface StringPrototypeExtensions {
|
||||
camelize(): string;
|
||||
decamelize(): string;
|
||||
classify(): string;
|
||||
capitalize(): string;
|
||||
loc(values?: string[]): string;
|
||||
dasherize(): string;
|
||||
underscore(): string;
|
||||
w(): string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a fullName return a factory manager.
|
||||
*/
|
||||
@@ -2439,7 +2417,7 @@ declare module 'ember' {
|
||||
function fmt(...args: string[]): string;
|
||||
function htmlSafe(str: string): Handlebars.SafeString;
|
||||
function isHTMLSafe(str: string): boolean;
|
||||
function loc(...args: string[]): string;
|
||||
function loc(template: string, args?: string[]): string;
|
||||
function underscore(str: string): string;
|
||||
function w(str: string): string[];
|
||||
}
|
||||
@@ -3142,7 +3120,7 @@ declare module 'ember' {
|
||||
* Merge the contents of two objects together into the first object.
|
||||
* @deprecated Use Object.assign
|
||||
*/
|
||||
function merge<T, U>(original: T, updates: U): T & U;
|
||||
function merge<T extends object, U extends object>(original: T, updates: U): Mix<T, U>;
|
||||
/**
|
||||
* Makes a method available via an additional name.
|
||||
*/
|
||||
@@ -3286,14 +3264,17 @@ declare module 'ember' {
|
||||
/**
|
||||
* Returns a consistent type for the passed object.
|
||||
*/
|
||||
function typeOf(item?: any): string;
|
||||
function typeOf<T>(value: T): KeysOfType<TypeLookup, T>;
|
||||
function typeOf(): 'undefined';
|
||||
function typeOf(item: any): string;
|
||||
/**
|
||||
* Copy properties from a source object to a target object.
|
||||
* @deprecated Use Object.assign
|
||||
*/
|
||||
function assign<T, U>(target: T, source: U): T & U;
|
||||
function assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
|
||||
function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
||||
function assign<T extends object, U extends object>(target: T, source: U): Mix<T, U>;
|
||||
function assign<T extends object, U extends object, V extends object>(target: T, source1: U, source2: V): Mix3<T, U, V>;
|
||||
function assign<T extends object, U extends object, V extends object, W extends object>(target: T, source1: U, source2: V, source3: W): Mix4<T, U, V, W>;
|
||||
|
||||
/**
|
||||
* Polyfill for Object.create
|
||||
* @deprecated Use Object.create
|
||||
@@ -3320,7 +3301,14 @@ declare module 'ember' {
|
||||
* Checks to see if the `methodName` exists on the `obj`,
|
||||
* and if it does, invokes it with the arguments passed.
|
||||
*/
|
||||
function tryInvoke(obj: any, methodName: string, args?: any[]): any;
|
||||
function tryInvoke<FNAME extends keyof T, T extends object>(
|
||||
obj: T,
|
||||
methodName: FNAME,
|
||||
args: FunctionArgs<T[FNAME]>): T[FNAME] extends ((...args: any[]) => any)
|
||||
? ReturnType<T[FNAME]>
|
||||
: undefined;
|
||||
function tryInvoke<FNAME extends keyof T, T extends object>(obj: T, methodName: FNAME): T[FNAME] extends (() => any) ? ReturnType<T[FNAME]> : undefined;
|
||||
function tryInvoke(obj: object, methodName: string, args?: any[]): undefined;
|
||||
/**
|
||||
* Forces the passed object to be part of an array. If the object is already
|
||||
* an array, it will return the object. Otherwise, it will add the object to
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Tests to ensure that access modifier keywords are appropriately
|
||||
* respected and supported
|
||||
*/
|
||||
import Ember from 'ember';
|
||||
import { assertType } from './lib/assert';
|
||||
|
||||
@@ -8,13 +12,16 @@ class Foo extends Ember.Object {
|
||||
}
|
||||
const f = new Foo();
|
||||
assertType<string>(f.hello());
|
||||
// protected property should not be visible from outside of Foo
|
||||
assertType<string>(f.bar()); // $ExpectError
|
||||
// private property should not be visible from outside of Foo
|
||||
assertType<string>(f.baz()); // $ExpectError
|
||||
|
||||
class Foo2 extends Ember.Object.extend({
|
||||
bar: ''
|
||||
}) {
|
||||
hello() { return 'world'; }
|
||||
// Cannot override with a mis-matched property type
|
||||
protected bar() { return 'bar'; } // $ExpectError
|
||||
private baz() { return 'baz'; }
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ import Component from '@ember/component';
|
||||
import Object, { computed } from '@ember/object';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
import { assertType } from "./lib/assert";
|
||||
import ComputedProperty from '@ember/object/computed';
|
||||
import { ExtractPropertyNamesOfType } from 'ember/-private-types/utils';
|
||||
import { UnwrapComputedPropertySetter } from 'ember/-private-types/object/computed';
|
||||
|
||||
Component.extend({
|
||||
layout: hbs`
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
import Ember from 'ember';
|
||||
import { assertType } from './lib/assert';
|
||||
|
||||
/** Newable tests */
|
||||
const co1 = new Ember.CoreObject();
|
||||
|
||||
// TODO: Enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
|
||||
// co1.concatenatedProperties; // $ExpectType string[]
|
||||
co1.isDestroyed; // $ExpectType boolean
|
||||
co1.isDestroying; // $ExpectType boolean
|
||||
co1.destroy(); // $ExpectType CoreObject
|
||||
co1.toString(); // $ExpectType string
|
||||
|
||||
/** .create tests */
|
||||
const co2 = Ember.CoreObject.create();
|
||||
// TODO: Enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
|
||||
// co2.concatenatedProperties; // $ExpectType string[]
|
||||
co2.isDestroyed; // $ExpectType boolean
|
||||
co2.isDestroying; // $ExpectType boolean
|
||||
co2.destroy(); // $ExpectType CoreObject
|
||||
co2.toString(); // $ExpectType string
|
||||
|
||||
/** .create tests w/ initial instance data passed in */
|
||||
const co3 = Ember.CoreObject.create({ foo: '123', bar: 456 });
|
||||
|
||||
co3.foo; // $ExpectType string
|
||||
co3.bar; // $ExpectType number
|
||||
|
||||
/** .extend with a zero-argument .create() */
|
||||
const co4 = Ember.CoreObject.extend({
|
||||
foo: '123',
|
||||
bar: 456,
|
||||
baz(): [string, number] {
|
||||
return [this.foo, this.bar];
|
||||
}
|
||||
}).create();
|
||||
|
||||
co4.foo; // $ExpectType string
|
||||
co4.bar; // $ExpectType number
|
||||
co4.baz; // $ExpectType () => [string, number]
|
||||
|
||||
/** .extend with inconsistent arguments passed into .create() */
|
||||
const class05 = Ember.CoreObject.extend({
|
||||
foo: '123' as (string | boolean),
|
||||
bar: 456,
|
||||
baz() {
|
||||
return [this.foo, this.bar];
|
||||
}
|
||||
});
|
||||
const c05 = class05.create({ foo: 99 }); // $ExpectError
|
||||
const c05b = class05.create({ foo: true });
|
||||
const c05c = class05.create({ foo: 'abc' });
|
||||
assertType<string>(c05b.foo); // $ExpectError
|
||||
assertType<boolean>(c05c.foo); // $ExpectError
|
||||
|
||||
/** two .extend arguments with a zero-argument .create() */
|
||||
const co6 = Ember.CoreObject.extend({
|
||||
foo: '123',
|
||||
bar: 456,
|
||||
baz() {
|
||||
return [this.foo, this.bar];
|
||||
},
|
||||
func1() {
|
||||
// this includes stuff from CoreObject
|
||||
this.init; // $ExpectType () => void
|
||||
// this includes stuff from this extend-arg
|
||||
this.foo; // $ExpectType string
|
||||
// this does not include stuff from later extend args
|
||||
this.bee; // $ExpectError
|
||||
}
|
||||
}, {
|
||||
foo: 99,
|
||||
bee: 'honey',
|
||||
func2() {
|
||||
// this includes stuff from CoreObject
|
||||
this.init; // $ExpectType () => void
|
||||
// this includes stuff from this extend-arg
|
||||
// TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
|
||||
this.foo; // $ExpectType string & number
|
||||
// this includes stuff from earlier extend-args
|
||||
this.bar; // $ExpectType number
|
||||
}
|
||||
}).create();
|
||||
|
||||
// TODO: enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
|
||||
// assertType<string>(co6.foo); // $ExpectError
|
||||
assertType<number>(co6.bar); // $ExpectType number
|
||||
assertType<() => Array<string | number>>(co6.baz); // $ExpectType () => (string | number)[]
|
||||
|
||||
/** three .extend arguments with a zero-argument .create() */
|
||||
const co7 = Ember.CoreObject.extend({
|
||||
foo: '123',
|
||||
bar: 456,
|
||||
baz() {
|
||||
return [this.foo, this.bar];
|
||||
},
|
||||
func1() {
|
||||
// this includes stuff from CoreObject
|
||||
this.init; // $ExpectType () => void
|
||||
// this includes stuff from this extend-arg
|
||||
this.foo; // $ExpectType string
|
||||
// this does not include stuff from later extend args
|
||||
this.bee; // $ExpectError
|
||||
}
|
||||
}, {
|
||||
foo: 99,
|
||||
bee: 'honey',
|
||||
func2() {
|
||||
// this includes stuff from CoreObject
|
||||
this.init; // $ExpectType () => void
|
||||
// this includes stuff from this extend-arg
|
||||
// TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
|
||||
this.foo; // $ExpectType string & number
|
||||
// this includes stuff from earlier extend-args
|
||||
this.bar; // $ExpectType number
|
||||
}
|
||||
}, {
|
||||
foo: '99',
|
||||
money: 'in the banana stand',
|
||||
func3() {
|
||||
// this includes stuff from CoreObject
|
||||
this.init; // $ExpectType () => void
|
||||
// this includes stuff from this extend-arg
|
||||
this.money; // $ExpectType string
|
||||
// this includes stuff from earlier extend-args
|
||||
this.bee; // $ExpectType string
|
||||
this.bar; // $ExpectType number
|
||||
}
|
||||
}).create();
|
||||
// TODO: enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
|
||||
// assertType<number>(co7.foo); // $ExpectError
|
||||
assertType<number>(co7.bar); // $ExpectType number
|
||||
assertType<string>(co7.money); // $ExpectType string
|
||||
assertType<() => Array<string | number>>(co7.baz); // $ExpectType () => (string | number)[]
|
||||
|
||||
/** four .extend arguments with a zero-argument .create() */
|
||||
const co8 = Ember.CoreObject.extend({
|
||||
foo: '123',
|
||||
bar: 456,
|
||||
baz() {
|
||||
return [this.foo, this.bar];
|
||||
},
|
||||
func1() {
|
||||
// this includes stuff from CoreObject
|
||||
this.init; // $ExpectType () => void
|
||||
// this includes stuff from this extend-arg
|
||||
this.foo; // $ExpectType string
|
||||
// this does not include stuff from later extend args
|
||||
this.bee; // $ExpectError
|
||||
}
|
||||
}, {
|
||||
foo: 99,
|
||||
bee: 'honey',
|
||||
func2() {
|
||||
// this includes stuff from CoreObject
|
||||
this.init; // $ExpectType () => void
|
||||
// this includes stuff from this extend-arg
|
||||
// TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
|
||||
this.foo; // $ExpectType string & number
|
||||
// this includes stuff from earlier extend-args
|
||||
this.bar; // $ExpectType number
|
||||
// this does not include stuff from later extend args
|
||||
this.money; // $ExpectError
|
||||
}
|
||||
}, {
|
||||
foo: '99',
|
||||
money: 'in the banana stand',
|
||||
func3() {
|
||||
// this includes stuff from CoreObject
|
||||
this.init; // $ExpectType () => void
|
||||
// this includes stuff from this extend-arg
|
||||
this.money; // $ExpectType string
|
||||
// this includes stuff from earlier extend-args
|
||||
this.bee; // $ExpectType string
|
||||
this.bar; // $ExpectType number
|
||||
// this does not include stuff from later extend args
|
||||
this.neighborhood; // $ExpectError
|
||||
}
|
||||
}, {
|
||||
foo: '99',
|
||||
neighborhood: 'sudden valley',
|
||||
func4() {
|
||||
// this includes stuff from CoreObject
|
||||
this.init; // $ExpectType () => void
|
||||
// this includes stuff from this extend-arg
|
||||
this.neighborhood; // $ExpectType string
|
||||
// this includes stuff from earlier extend-args
|
||||
this.bee; // $ExpectType string
|
||||
this.bar; // $ExpectType number
|
||||
this.money; // $ExpectType string
|
||||
}
|
||||
}).create();
|
||||
|
||||
// TODO: enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
|
||||
// assertType<number>(co8.foo); // $ExpectError
|
||||
assertType<number>(co8.bar); // $ExpectType number
|
||||
assertType<string>(co8.money); // $ExpectType string
|
||||
assertType<() => Array<string | number>>(co8.baz); // $ExpectType () => (string | number)[]
|
||||
@@ -2,4 +2,4 @@
|
||||
// Disable tslint here b/c the generic is used to let us do a type coercion and
|
||||
// validate that coercion works for the type value "passed into" the function.
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
export declare function assertType<T>(value: T): void;
|
||||
export declare function assertType<T>(value: T): T;
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import { Ember } from "ember";
|
||||
import { computed } from "@ember/object";
|
||||
import { UnwrapComputedPropertySetters, UnwrapComputedPropertyGetters, UnwrapComputedPropertySetter, UnwrapComputedPropertyGetter } from "ember/-private-types/object/computed";
|
||||
import ComputedProperty from "@ember/object/computed";
|
||||
import { assertType } from "../lib/assert";
|
||||
|
||||
class Example1 extends Ember.Object.extend({
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
allNames: computed('fullName', function() {
|
||||
return [this.fullName];
|
||||
}),
|
||||
fullName: computed('firstName', 'lastName', function() {
|
||||
return `${this.firstName} ${this.lastName}`;
|
||||
})
|
||||
}) {
|
||||
allNames!: ComputedProperty<string[]>;
|
||||
fullName!: ComputedProperty<string>;
|
||||
}
|
||||
|
||||
let unwrappedGetters1: UnwrapComputedPropertyGetters<Example1> = {} as any;
|
||||
unwrappedGetters1.firstName; // $ExpectType string
|
||||
unwrappedGetters1.lastName; // $ExpectType string
|
||||
unwrappedGetters1.fullName; // $ExpectType string
|
||||
unwrappedGetters1.allNames; // $ExpectType string[]
|
||||
|
||||
let unwrappedSetters1: UnwrapComputedPropertySetters<Example1> = {} as any;
|
||||
unwrappedSetters1.firstName; // $ExpectType string
|
||||
unwrappedSetters1.lastName; // $ExpectType string
|
||||
unwrappedSetters1.fullName; // $ExpectType string
|
||||
unwrappedSetters1.allNames; // $ExpectType string[]
|
||||
|
||||
class Example2 extends Ember.Object.extend({
|
||||
allNames: computed('fullName', function() {
|
||||
return [this.fullName + ''];
|
||||
}) ,
|
||||
fullName: computed('firstName', 'lastName', function() {
|
||||
return `${this.firstName} ${this.lastName}`;
|
||||
})
|
||||
}) {
|
||||
firstName = '';
|
||||
lastName = '';
|
||||
foo() {
|
||||
this.fullName; // $ExpectType ComputedProperty<string, string>
|
||||
this.allNames; // $ExpectType ComputedProperty<string[], string[]>
|
||||
this.firstName; // $ExpectType string
|
||||
this.lastName; // $ExpectType string
|
||||
|
||||
this.get('fullName').split(','); // $ExpectType string[]
|
||||
this.get('allNames')[0]; // $ExpectType string
|
||||
this.get('firstName').split(','); // $ExpectType string[]
|
||||
this.get('lastName').split(','); // $ExpectType string[]
|
||||
}
|
||||
}
|
||||
let ex2 = new Example2();
|
||||
|
||||
let unwrappedGetters2: UnwrapComputedPropertyGetters<typeof ex2> = (ex2 as any) as UnwrapComputedPropertyGetters<typeof ex2>;
|
||||
assertType<string>(unwrappedGetters2.firstName); // $ExpectType string
|
||||
assertType<string>(unwrappedGetters2.lastName); // $ExpectType string
|
||||
assertType<string>(unwrappedGetters2.fullName); // $ExpectType string
|
||||
assertType<string[]>(unwrappedGetters2.allNames); // $ExpectType string[]
|
||||
|
||||
let unwrappedSetters2: UnwrapComputedPropertySetters<typeof ex2> = null as any;
|
||||
assertType<string>(unwrappedSetters2.firstName); // $ExpectType string
|
||||
assertType<string>(unwrappedSetters2.lastName); // $ExpectType string
|
||||
assertType<string>(unwrappedSetters2.fullName); // $ExpectType string
|
||||
assertType<string[]>(unwrappedSetters2.allNames); // $ExpectType string[]
|
||||
|
||||
ex2.fullName; // $ExpectType ComputedProperty<string, string>
|
||||
ex2.allNames; // $ExpectType ComputedProperty<string[], string[]>
|
||||
ex2.firstName; // $ExpectType string
|
||||
|
||||
type UnwStringSet = UnwrapComputedPropertySetter<string>; // $ExpectType string
|
||||
type UnwStringGet = UnwrapComputedPropertyGetter<string>; // $ExpectType string
|
||||
type UnwCpStringSet1 = UnwrapComputedPropertySetter<ComputedProperty<string>>; // $ExpectType string
|
||||
type UnwCpStringGet1 = UnwrapComputedPropertyGetter<ComputedProperty<string>>; // $ExpectType string
|
||||
type UnwCpStringSet2 = UnwrapComputedPropertySetter<ComputedProperty<string, string>>; // $ExpectType string
|
||||
type UnwCpStringGet2 = UnwrapComputedPropertyGetter<ComputedProperty<string, string>>; // $ExpectType string
|
||||
type UnwCpStringSet3 = UnwrapComputedPropertySetter<ComputedProperty<number, string>>; // $ExpectType string
|
||||
type UnwCpStringGet3 = UnwrapComputedPropertyGetter<ComputedProperty<number, string>>; // $ExpectType number
|
||||
type UnwCpStringSet4 = UnwrapComputedPropertySetter<ComputedProperty<string, number>>; // $ExpectType number
|
||||
type UnwCpStringGet4 = UnwrapComputedPropertyGetter<ComputedProperty<string, number>>; // $ExpectType string
|
||||
@@ -0,0 +1,175 @@
|
||||
import Observable from "@ember/object/observable";
|
||||
import { UnwrapComputedPropertyGetter, UnwrapComputedPropertyGetters, UnwrapComputedPropertySetters, UnwrapComputedPropertySetter } from "ember/-private-types/object/computed";
|
||||
// tslint-disable-next-line
|
||||
import { assertType } from "../lib/assert";
|
||||
import { Ember } from "ember";
|
||||
import { ExtractPropertyNamesOfType } from "ember/-private-types/utils";
|
||||
|
||||
class OtherThing {
|
||||
observerOfDemo(target: DemoObservable, key: 'foo') {}
|
||||
}
|
||||
|
||||
class DemoObservable implements Observable {
|
||||
foo: string;
|
||||
isFoo = true;
|
||||
bar: [boolean, boolean];
|
||||
baz?: number;
|
||||
constructor() {
|
||||
this.foo = 'hello';
|
||||
this.bar = [false, true];
|
||||
this.baz = 9;
|
||||
this.addObserver('foo', this, 'fooDidChange');
|
||||
this.addObserver('foo', this, 'fooDidChangeProtected'); // $ExpectError
|
||||
this.addObserver('foo', this, this.fooDidChange);
|
||||
this.addObserver('foo', this, this.fooDidChangeProtected);
|
||||
const ot = new OtherThing();
|
||||
this.addObserver('foo', ot, ot.observerOfDemo);
|
||||
Ember.addObserver(this, 'foo', this, 'fooDidChange');
|
||||
Ember.addObserver(this, 'foo', this, 'fooDidChangeProtected'); // $ExpectError
|
||||
Ember.addObserver(this, 'foo', this, this.fooDidChange);
|
||||
Ember.addObserver(this, 'foo', this, this.fooDidChangeProtected);
|
||||
this.removeObserver('foo', this, 'fooDidChange');
|
||||
this.removeObserver('foo', this, 'fooDidChangeProtected'); // $ExpectError
|
||||
this.removeObserver('foo', this, this.fooDidChange);
|
||||
this.removeObserver('foo', this, this.fooDidChangeProtected);
|
||||
Ember.removeObserver(this, 'foo', this, 'fooDidChange');
|
||||
Ember.removeObserver(this, 'foo', this, 'fooDidChangeProtected'); // $ExpectError
|
||||
Ember.removeObserver(this, 'foo', this, this.fooDidChange);
|
||||
const lambda = () => {
|
||||
this.fooDidChange(this, 'foo');
|
||||
};
|
||||
this.addObserver('foo', lambda);
|
||||
this.addObserver('foo', (sender, key, value, rev) => {
|
||||
assertType<DemoObservable>(sender);
|
||||
assertType<'foo'>(key);
|
||||
assertType<string>(value);
|
||||
assertType<number>(rev);
|
||||
});
|
||||
this.removeObserver('foo', lambda);
|
||||
Ember.addObserver(this, 'foo', lambda);
|
||||
Ember.removeObserver(this, 'foo', lambda);
|
||||
}
|
||||
|
||||
fooDidChange(obj: this, propName: 'foo') {}
|
||||
protected fooDidChangeProtected(obj: this, propName: 'foo') {}
|
||||
get<K extends keyof this>(key: K): UnwrapComputedPropertyGetter<this[K]> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
getProperties<K extends keyof this>(list: K[]): Pick<UnwrapComputedPropertyGetters<this>, K>;
|
||||
getProperties<K extends keyof this>(...list: K[]): Pick<UnwrapComputedPropertyGetters<this>, K>;
|
||||
getProperties(...rest: any[]): any {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
set<K extends keyof this>(key: K, value: this[K]): this[K] {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
setProperties<K extends keyof this>(hash: Pick<this, K>): Pick< UnwrapComputedPropertySetters<this>, K> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
notifyPropertyChange(keyName: string): this {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
addObserver<Target>(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: keyof this, value: any, rev: number) => void)): void;
|
||||
addObserver<K extends keyof this>(key: K, method: keyof this | ((this: this, sender: this, key: K, value: this[K], rev: number) => void)): void;
|
||||
addObserver(key: any, target: any, method?: any) {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
removeObserver<Target>(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: keyof this, value: any, rev: number) => void)): void;
|
||||
removeObserver(key: keyof this, method: keyof this | ((this: this, sender: this, key: string, value: any, rev: number) => void)): void;
|
||||
removeObserver(key: any, target: any, method?: any): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
getWithDefault<K extends keyof this>(key: K, defaultValue: UnwrapComputedPropertyGetter<this[K]>): UnwrapComputedPropertyGetter<this[K]> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
incrementProperty(keyName: ExtractPropertyNamesOfType<this, number | undefined>, increment?: number): number {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
decrementProperty(keyName: ExtractPropertyNamesOfType<this, number | undefined>, decrement?: number): number {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
toggleProperty(keyName: ExtractPropertyNamesOfType<this, boolean | undefined>): boolean {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
cacheFor<K extends keyof this>(key: K): UnwrapComputedPropertyGetter<this[K]> | undefined {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
const o = new DemoObservable();
|
||||
|
||||
/**
|
||||
* get
|
||||
*/
|
||||
assertType<string>(o.get('foo')); // $ExpectType string
|
||||
assertType<[boolean, boolean]>(o.get('bar')); // $ExpectType [boolean, boolean]
|
||||
assertType<number | undefined>(o.get('baz')); // $ExpectType number | undefined
|
||||
|
||||
/**
|
||||
* incrementProperty, decrementProperty
|
||||
*/
|
||||
assertType<number>(o.incrementProperty('baz')); // $ExpectType number
|
||||
assertType<number>(o.decrementProperty('baz')); // $ExpectType number
|
||||
assertType<number>(o.incrementProperty('baz', 3)); // $ExpectType number
|
||||
assertType<number>(o.decrementProperty('baz', 12)); // $ExpectType number
|
||||
// non-numeric property case
|
||||
assertType<number>(o.incrementProperty('bar')); // $ExpectError
|
||||
assertType<number>(o.decrementProperty('bar')); // $ExpectError
|
||||
// empty case
|
||||
assertType<number>(o.incrementProperty()); // $ExpectError
|
||||
assertType<number>(o.decrementProperty()); // $ExpectError
|
||||
|
||||
/**
|
||||
* toggleProperty
|
||||
*/
|
||||
o.toggleProperty('isFoo'); // $ExpectType boolean
|
||||
o.toggleProperty(); // $ExpectError
|
||||
|
||||
/**
|
||||
* getWithDefault
|
||||
*/
|
||||
assertType<string>(o.getWithDefault('foo', 'zzz')); // $ExpectType string
|
||||
assertType<[boolean, boolean]>(o.getWithDefault('bar', [false, false])); // $ExpectType [boolean, boolean]
|
||||
assertType<number | undefined>(o.getWithDefault('baz', 10)); // $ExpectType number | undefined
|
||||
// improper arguments cases
|
||||
assertType<number | undefined>(o.getWithDefault('baz', '10')); // $ExpectError
|
||||
assertType<number | undefined>(o.getWithDefault('baz')); // $ExpectError
|
||||
assertType<number | undefined>(o.getWithDefault()); // $ExpectError
|
||||
|
||||
/**
|
||||
* getProperties
|
||||
*/
|
||||
// ('foo', 'bar')
|
||||
assertType<{ foo: string, bar: [boolean, boolean] }>(o.getProperties('foo', 'bar')); // $ExpectType { foo: string; bar: [boolean, boolean]; }
|
||||
// ['foo', 'bar']
|
||||
assertType<{ foo: string, bar: [boolean, boolean] }>(o.getProperties(['foo', 'bar'])); // $ExpectType { foo: string; bar: [boolean, boolean]; }
|
||||
// empty cases
|
||||
assertType<{}>(o.getProperties()); // $ExpectType {}
|
||||
assertType<{}>(o.getProperties([])); // $ExpectType {}
|
||||
// property that doesn't exist
|
||||
assertType<any>(o.getProperties('jeanShorts', 'foo')); // $ExpectError
|
||||
assertType<any>(o.getProperties(['foo', 'jeanShorts'])); // $ExpectError
|
||||
|
||||
/**
|
||||
* set
|
||||
*/
|
||||
assertType<string>(o.set('foo', 'abc')); // $ExpectType string
|
||||
assertType<[boolean, boolean]>(o.set('bar', [false, false])); // $ExpectType [boolean, boolean]
|
||||
assertType<number | undefined>(o.set('baz', undefined)); // $ExpectType number | undefined
|
||||
assertType<number | undefined>(o.set('baz', 10)); // $ExpectType number | undefined
|
||||
// property that doesn't exist
|
||||
assertType<any>(o.set('jeanShorts', 10)); // $ExpectError
|
||||
|
||||
/**
|
||||
* setProperties
|
||||
*/
|
||||
assertType<{ foo: string, bar: [boolean, boolean] }>(o.setProperties({ foo: 'abc', bar: [true, true] })); // $ExpectType { foo: string; bar: [boolean, boolean]; }
|
||||
// empty case
|
||||
assertType<{}>(o.setProperties({})); // $ExpectType {}
|
||||
// property that doesn't exist
|
||||
assertType<any>(o.setProperties({ jeanShorts: 'under the pants' })); // $ExpectError
|
||||
|
||||
/**
|
||||
* notifyPropertyChange
|
||||
*/
|
||||
assertType<DemoObservable>(o.notifyPropertyChange('foo')); // $ExpectType DemoObservable
|
||||
assertType<Observable>(o.notifyPropertyChange('jeanShorts')); // $ExpectError
|
||||
@@ -0,0 +1,28 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
declare global {
|
||||
interface String extends Ember.StringPrototypeExtensions {}
|
||||
}
|
||||
|
||||
''.dasherize('foo'); // $ExpectError
|
||||
''.dasherize(); // $ExpectType string
|
||||
|
||||
''.camelize(); // $ExpectType string
|
||||
''.camelize('blue man group'); // $ExpectError
|
||||
|
||||
''.decamelize(); // $ExpectType string
|
||||
''.decamelize('blue man group'); // $ExpectError
|
||||
|
||||
''.underscore(); // $ExpectType string
|
||||
''.underscore('blue man group'); // $ExpectError
|
||||
|
||||
''.w(); // $ExpectType string[]
|
||||
|
||||
''.classify(); // $ExpectType string
|
||||
''.classify('blue man group'); // $ExpectError
|
||||
|
||||
''.capitalize(); // $ExpectType string
|
||||
''.capitalize('blue man group'); // $ExpectError
|
||||
|
||||
''.loc(); // $ExpectType string
|
||||
''.loc("_Hello World"); // $ExpectError
|
||||
@@ -0,0 +1,36 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
const { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w } = Ember.String;
|
||||
|
||||
dasherize(); // $ExpectError
|
||||
dasherize('blue man group'); // $ExpectType string
|
||||
dasherize('', ''); // $ExpectError
|
||||
|
||||
camelize(); // $ExpectError
|
||||
camelize('blue man group'); // $ExpectType string
|
||||
camelize('', ''); // $ExpectError
|
||||
|
||||
decamelize(); // $ExpectError
|
||||
decamelize('blue man group'); // $ExpectType string
|
||||
decamelize('', ''); // $ExpectError
|
||||
|
||||
underscore(); // $ExpectError
|
||||
underscore('blue man group'); // $ExpectType string
|
||||
underscore('', ''); // $ExpectError
|
||||
|
||||
w(); // $ExpectError
|
||||
w('blue man group'); // $ExpectType string[]
|
||||
w('', ''); // $ExpectError
|
||||
|
||||
classify(); // $ExpectError
|
||||
classify('blue man group'); // $ExpectType string
|
||||
classify('', ''); // $ExpectError
|
||||
|
||||
capitalize(); // $ExpectError
|
||||
capitalize('blue man group'); // $ExpectType string
|
||||
capitalize('', ''); // $ExpectError
|
||||
|
||||
loc(); // $ExpectError
|
||||
loc("_Hello World"); // $ExpectType string
|
||||
// TODO - fix this case upstream in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/281
|
||||
loc("_Hello %@ %@", ["John", "Smith"]); // $ExpectType string
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* These tests validate that the method of pulling property types off of this
|
||||
* continues to work. We use this technique in the critical Observable interface
|
||||
* that serves to implement a lot of Ember.CoreObject's functionality
|
||||
*/
|
||||
|
||||
class BoxedProperty<Get, Set = Get> {
|
||||
__getType: Get;
|
||||
__setType: Set;
|
||||
}
|
||||
|
||||
type UnboxGetProperty<T> = T extends BoxedProperty<infer V, any> ? V : T;
|
||||
type UnboxSetProperty<T> = T extends BoxedProperty<any, infer V> ? V : T;
|
||||
|
||||
class GetAndSet {
|
||||
get<K extends keyof this>(key: K): UnboxGetProperty<this[K]> {
|
||||
return this[key] as any;
|
||||
}
|
||||
set<K extends keyof this>(key: K, newVal: UnboxSetProperty<this[K]>): UnboxSetProperty<this[K]> {
|
||||
const rawVal: UnboxSetProperty<this[K]> = this[key] as any;
|
||||
if (rawVal instanceof BoxedProperty) {
|
||||
rawVal.__setType = newVal;
|
||||
}
|
||||
this[key] = newVal as any;
|
||||
return newVal;
|
||||
}
|
||||
}
|
||||
|
||||
class Foo123 extends GetAndSet {
|
||||
// tslint:disable-next-line:no-inferrable-types
|
||||
a: number;
|
||||
b: [boolean, boolean];
|
||||
c: string;
|
||||
cpA!: BoxedProperty<string>;
|
||||
constructor() {
|
||||
super();
|
||||
this.a = 1;
|
||||
this.b = [true, false];
|
||||
this.c = 'hello';
|
||||
}
|
||||
}
|
||||
|
||||
let f = new Foo123();
|
||||
|
||||
f.get('a'); // $ExpectType number
|
||||
f.set('a'); // $ExpectError
|
||||
f.set('a', '1'); // $ExpectError
|
||||
f.set('a', 1); // $ExpectType number
|
||||
|
||||
f.get('b'); // $ExpectType [boolean, boolean]
|
||||
f.set('b', 1); // $ExpectError
|
||||
f.set('b', []); // $ExpectError
|
||||
f.set('b', [true]); // $ExpectError
|
||||
f.set('b', [false, true]); // $ExpectType [boolean, boolean]
|
||||
f.set('b', [false, true, false]); // $ExpectError
|
||||
|
||||
f.get('c'); // $ExpectType string
|
||||
f.set('c', '1'); // $ExpectType string
|
||||
|
||||
f.get('cpA'); // $ExpectType string
|
||||
f.set('cpA', ['newValue']); // $ExpectError
|
||||
f.set('cpA', 'newValue'); // $ExpectType string
|
||||
@@ -3,8 +3,8 @@ import * as utils from '@ember/utils';
|
||||
import { assertType } from "./lib/assert";
|
||||
|
||||
function testTypeOf() {
|
||||
utils.typeOf(); // $ExpectType string
|
||||
utils.typeOf({}); // $ExpectType string
|
||||
utils.typeOf(); // $ExpectType "undefined"
|
||||
const str: string = utils.typeOf({});
|
||||
}
|
||||
|
||||
function testIsNoneType() {
|
||||
@@ -99,3 +99,78 @@ function testDefineProperty() {
|
||||
return `${this.firstName} ${this.lastName}`;
|
||||
}));
|
||||
}
|
||||
|
||||
function testTryInvoke() {
|
||||
class Foo {
|
||||
hello() { return ['world']; }
|
||||
add(x: number, y: string) { return x + parseInt(y, 10); }
|
||||
apples(n: number) { return `${n} apples`; }
|
||||
}
|
||||
// zero-argument function
|
||||
Ember.tryInvoke(new Foo(), 'hello'); // $ExpectType string[]
|
||||
// one-argument function
|
||||
Ember.tryInvoke(new Foo(), 'apples', [4]); // $ExpectType string
|
||||
// multi-argument function with different types (reversed types negative test case below)
|
||||
Ember.tryInvoke(new Foo(), 'add', [4, '3']); // $ExpectType number
|
||||
|
||||
// Cases that should return undefined
|
||||
// No args provided
|
||||
Ember.tryInvoke(new Foo(), 'apples'); // $ExpectType undefined
|
||||
// Function does not exist
|
||||
Ember.tryInvoke(new Foo(), 'doesNotExist'); // $ExpectType undefined
|
||||
// Empty args provided
|
||||
Ember.tryInvoke(new Foo(), 'apples', []); // $ExpectType undefined
|
||||
// Wrong args provided
|
||||
Ember.tryInvoke(new Foo(), 'apples', ['']); // $ExpectType undefined
|
||||
// Wrong arg types
|
||||
Ember.tryInvoke(new Foo(), 'add', [4, 3]); // $ExpectType undefined
|
||||
// Reversed arg types
|
||||
Ember.tryInvoke(new Foo(), 'add', ['4', 3]); // $ExpectType undefined
|
||||
}
|
||||
|
||||
(function() {
|
||||
/** typeOf */
|
||||
// TODO: more specific return type in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/259
|
||||
Ember.typeOf(); // $ExpectType "undefined"
|
||||
Ember.typeOf(null); // $ExpectType "null"
|
||||
Ember.typeOf(undefined); // $ExpectType "undefined"
|
||||
Ember.typeOf('michael'); // $ExpectType "string"
|
||||
// tslint:disable-next-line:no-construct
|
||||
Ember.typeOf(new String('michael')); // $ExpectType "string"
|
||||
Ember.typeOf(101); // $ExpectType "number"
|
||||
// tslint:disable-next-line:no-construct
|
||||
Ember.typeOf(new Number(101)); // $ExpectType "number"
|
||||
Ember.typeOf(true); // $ExpectType "boolean"
|
||||
// tslint:disable-next-line:no-construct
|
||||
Ember.typeOf(new Boolean(true)); // $ExpectType "boolean"
|
||||
Ember.typeOf(() => 4); // $ExpectType "function"
|
||||
Ember.typeOf([1, 2, 90]); // $ExpectType "array"
|
||||
Ember.typeOf(/abc/); // $ExpectType "regexp"
|
||||
Ember.typeOf(new Date()); // $ExpectType "date"
|
||||
Ember.typeOf(({} as any) as FileList); // $ExpectType "filelist"
|
||||
Ember.typeOf(Ember.Object.extend()); // $ExpectType "class"
|
||||
Ember.typeOf(Ember.Object.create()); // $ExpectType "instance"
|
||||
Ember.typeOf(new Error('teamocil')); // $ExpectType "error"
|
||||
Ember.typeOf((new Date()) as RegExp | Date); // "regexp" | "date"
|
||||
})();
|
||||
|
||||
(function() { /* assign */
|
||||
Ember.assign({}, { a: 'b'});
|
||||
Ember.assign({}, { a: 'b'}).a; // $ExpectType string
|
||||
Ember.assign({ a: 6 }, { a: 'b'}).a; // $ExpectType string
|
||||
Ember.assign({ a: 6 }, {}).a; // $ExpectType number
|
||||
Ember.assign({ b: 6 }, {}).a; // $ExpectError
|
||||
Ember.assign({}, { b: 6 }, {}).b; // $ExpectType number
|
||||
Ember.assign({ a: 'hello' }, { b: 6 }, {}).a; // $ExpectType string
|
||||
Ember.assign({ a: 'hello' }, { b: 6 }, { a: true }).a; // $ExpectType boolean
|
||||
Ember.assign({ a: 'hello' }, '', { a: true }).a; // $ExpectError
|
||||
Ember.assign({ d: ['gobias industries'] }, { a: 'hello' }, { b: 6 }, { a: true }).d; // $ExpectType string[]
|
||||
}());
|
||||
|
||||
(function() { /* merge */
|
||||
Ember.merge({}, { a: 'b'});
|
||||
Ember.merge({}, { a: 'b'}).a; // $ExpectType string
|
||||
Ember.merge({ a: 6 }, { a: 'b'}).a; // $ExpectType string
|
||||
Ember.merge({ a: 6 }, {}).a; // $ExpectType number
|
||||
Ember.merge({ b: 6 }, {}).a; // $ExpectError
|
||||
}());
|
||||
|
||||
+30
-21
@@ -20,40 +20,49 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"-private-types/utils.d.ts",
|
||||
"-private-types/mixin.d.ts",
|
||||
"-private-types/object.d.ts",
|
||||
"-private-types/object/computed.d.ts",
|
||||
"test/lib/assert.ts",
|
||||
"test/application.ts",
|
||||
"test/private/computed-tests.ts",
|
||||
"test/private/observable-tests.ts",
|
||||
"test/techniques/properties-from-this.ts",
|
||||
"test/access-modifier.ts",
|
||||
"test/application-instance.ts",
|
||||
"test/engine.ts",
|
||||
"test/engine-instance.ts",
|
||||
"test/application.ts",
|
||||
"test/array-ext.ts",
|
||||
"test/array-proxy.ts",
|
||||
"test/array.ts",
|
||||
"test/component.ts",
|
||||
"test/computed.ts",
|
||||
"test/controller.ts",
|
||||
"test/core-object.ts",
|
||||
"test/create-negative.ts",
|
||||
"test/create.ts",
|
||||
"test/detect-instance.ts",
|
||||
"test/detect.ts",
|
||||
"test/ember-tests.ts",
|
||||
"test/engine-instance.ts",
|
||||
"test/engine.ts",
|
||||
"test/error.ts",
|
||||
"test/event.ts",
|
||||
"test/extend.ts",
|
||||
"test/create.ts",
|
||||
"test/create-negative.ts",
|
||||
"test/create.ts",
|
||||
"test/function-ext.ts",
|
||||
"test/helper.ts",
|
||||
"test/inject.ts",
|
||||
"test/mixin.ts",
|
||||
"test/object.ts",
|
||||
"test/observable.ts",
|
||||
"test/mixin.ts",
|
||||
"test/reopen.ts",
|
||||
"test/detect.ts",
|
||||
"test/detect-instance.ts",
|
||||
"test/array.ts",
|
||||
"test/array-ext.ts",
|
||||
"test/array-proxy.ts",
|
||||
"test/helper.ts",
|
||||
"test/computed.ts",
|
||||
"test/component.ts",
|
||||
"test/function-ext.ts",
|
||||
"test/inject.ts",
|
||||
"test/utils.ts",
|
||||
"test/transition.ts",
|
||||
"test/route.ts",
|
||||
"test/router.ts",
|
||||
"test/run.ts",
|
||||
"test/string.ts",
|
||||
"test/string-ext.ts",
|
||||
"test/test.ts",
|
||||
"test/controller.ts",
|
||||
"test/route.ts",
|
||||
"test/transition.ts",
|
||||
"test/utils.ts",
|
||||
"test/view-utils.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class Checkbox extends Ember.Checkbox { }
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class Helper extends Ember.Helper { }
|
||||
/**
|
||||
* In many cases, the ceremony of a full `Helper` class is not required.
|
||||
* The `helper` method create pure-function helpers without instances. For
|
||||
* example:
|
||||
* ```app/helpers/format-currency.js
|
||||
* import { helper } from '@ember/component/helper';
|
||||
* export default helper(function(params, hash) {
|
||||
* let cents = params[0];
|
||||
* let currency = hash.currency;
|
||||
* return `${currency}${cents * 0.01}`;
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function helper(helperFn: (params: any[], hash?: any) => any): any;
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// Type definitions for @ember/component 3.0
|
||||
// Project: http://emberjs.com/
|
||||
// Definitions by: Mike North <https://github.com/mike-north>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class Component extends Ember.Component { }
|
||||
@@ -0,0 +1,123 @@
|
||||
import Component from '@ember/component';
|
||||
import Object, { computed, get } from '@ember/object';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
import { assertType } from "./lib/assert";
|
||||
|
||||
Component.extend({
|
||||
layout: hbs`
|
||||
<div>
|
||||
{{yield}}
|
||||
</div>
|
||||
`,
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
layout: 'my-layout',
|
||||
});
|
||||
|
||||
const MyComponent = Component.extend();
|
||||
assertType<string | string[]>(get(MyComponent, 'positionalParams'));
|
||||
|
||||
const component1 = Component.extend({
|
||||
actions: {
|
||||
hello(name: string) {
|
||||
console.log('Hello', name);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
name: '',
|
||||
hello(name: string) {
|
||||
this.set('name', name);
|
||||
},
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
tagName: 'em',
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
classNames: ['my-class', 'my-other-class'],
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
classNameBindings: ['propertyA', 'propertyB'],
|
||||
propertyA: 'from-a',
|
||||
propertyB: computed(function() {
|
||||
if (!this.get('propertyA')) {
|
||||
return 'from-b';
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
classNameBindings: ['hovered'],
|
||||
hovered: true,
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
classNameBindings: ['messages.empty'],
|
||||
messages: Object.create({
|
||||
empty: true,
|
||||
}),
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
classNameBindings: ['isEnabled:enabled:disabled'],
|
||||
isEnabled: true,
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
classNameBindings: ['isEnabled::disabled'],
|
||||
isEnabled: true,
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
tagName: 'a',
|
||||
attributeBindings: ['href'],
|
||||
href: 'http://google.com',
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
tagName: 'a',
|
||||
attributeBindings: ['url:href'],
|
||||
url: 'http://google.com',
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
tagName: 'use',
|
||||
attributeBindings: ['xlinkHref:xlink:href'],
|
||||
xlinkHref: '#triangle',
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
tagName: 'input',
|
||||
attributeBindings: ['disabled'],
|
||||
disabled: false,
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
tagName: 'input',
|
||||
attributeBindings: ['disabled'],
|
||||
disabled: computed(() => {
|
||||
if ('someLogic') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
tagName: 'form',
|
||||
attributeBindings: ['novalidate'],
|
||||
novalidate: null,
|
||||
});
|
||||
|
||||
Component.extend({
|
||||
click(event: object) {
|
||||
// will be called when an instance's
|
||||
// rendered element is clicked
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { assertType } from './lib/assert';
|
||||
import Helper, { helper } from '@ember/component/helper';
|
||||
|
||||
class Timestamp extends Helper {
|
||||
timer?: ReturnType<typeof setInterval>;
|
||||
now = new Date();
|
||||
init() {
|
||||
super.init();
|
||||
this.timer = setInterval(() => {
|
||||
this.set('now', new Date());
|
||||
this.recompute();
|
||||
}, 100);
|
||||
}
|
||||
willDestroy() {
|
||||
clearInterval(this.timer);
|
||||
}
|
||||
}
|
||||
|
||||
const addHelper = helper(function add([a, b]: number[]) {
|
||||
return a + b;
|
||||
});
|
||||
|
||||
const dasherizeHelper = helper(function dasherize([str]: string[], { delim = '-'}) {
|
||||
return str.split(/[\s\n\_\.]+/g).join(delim);
|
||||
});
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
/** Static assertion that `value` has type `T` */
|
||||
// Disable tslint here b/c the generic is used to let us do a type coercion and
|
||||
// validate that coercion works for the type value "passed into" the function.
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
export declare function assertType<T>(value: T): T;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class TextArea extends Ember.TextArea { }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class TextField extends Ember.TextField { }
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@ember/component": ["ember__component"],
|
||||
"@ember/component/*": ["ember__component/*"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"checkbox.d.ts",
|
||||
"text-area.d.ts",
|
||||
"text-field.d.ts",
|
||||
"helper.d.ts",
|
||||
"test/lib/assert.ts",
|
||||
"test/component.ts",
|
||||
"test/helper.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import Controller from '@ember/controller';
|
||||
|
||||
Controller.extend ({
|
||||
queryParams: ['category'],
|
||||
category: null,
|
||||
isExpanded: false,
|
||||
|
||||
toggleBody() {
|
||||
this.toggleProperty('isExpanded');
|
||||
}
|
||||
});
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for @ember/controller 3.0
|
||||
// Project: http://emberjs.com/
|
||||
// Definitions by: Mike North <https://github.com/mike-north>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class Controller extends Ember.Controller { }
|
||||
export const inject: typeof Ember.inject.controller;
|
||||
|
||||
// A type registry for Ember `Controller`s. Meant to be declaration-merged
|
||||
// so string lookups resolve to the correct type.
|
||||
// tslint:disable-next-line no-empty-interface
|
||||
export interface Registry {}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@ember/controller": ["ember__controller"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ember__controller-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {}
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// Type definitions for @ember/engine 3.0
|
||||
// Project: http://emberjs.com/
|
||||
// Definitions by: Mike North <https://github.com/mike-north>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class Engine extends Ember.Engine { }
|
||||
export const getEngineParent: typeof Ember.getEngineParent;
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class EngineInstance extends Ember.EngineInstance { }
|
||||
@@ -0,0 +1,26 @@
|
||||
import EngineInstance from '@ember/engine/instance';
|
||||
|
||||
const engineInstance = EngineInstance.create();
|
||||
engineInstance.register('some:injection', class Foo {});
|
||||
|
||||
engineInstance.register('some:injection', class Foo {}, {
|
||||
singleton: true,
|
||||
});
|
||||
|
||||
engineInstance.register('some:injection', class Foo {}, {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
engineInstance.register('some:injection', class Foo {}, {
|
||||
singleton: false,
|
||||
instantiate: true,
|
||||
});
|
||||
|
||||
engineInstance.factoryFor('router:main');
|
||||
engineInstance.lookup('route:basic');
|
||||
|
||||
engineInstance.boot();
|
||||
|
||||
(async () => {
|
||||
await engineInstance.boot();
|
||||
})();
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
import Engine from "@ember/engine";
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
const BaseEngine = Engine.extend({
|
||||
modulePrefix: 'my-engine'
|
||||
});
|
||||
|
||||
BaseEngine.initializer({
|
||||
name: 'my-initializer',
|
||||
initialize(engine) {
|
||||
engine.register('foo:bar', EmberObject.extend({ foo: 'bar' }));
|
||||
}
|
||||
});
|
||||
|
||||
BaseEngine.instanceInitializer({
|
||||
name: 'my-instance-initializer',
|
||||
initialize(engine) {
|
||||
engine.lookup('foo:bar').get('foo');
|
||||
}
|
||||
});
|
||||
|
||||
const Engine1 = BaseEngine.create({
|
||||
rootElement: '#engine-one',
|
||||
customEvents: {
|
||||
paste: 'paste'
|
||||
}
|
||||
});
|
||||
|
||||
const Engine2 = BaseEngine.create({
|
||||
rootElement: '#engine-two',
|
||||
customEvents: {
|
||||
mouseenter: null,
|
||||
mouseleave: null
|
||||
}
|
||||
});
|
||||
|
||||
const Engine3 = BaseEngine.create();
|
||||
|
||||
const Engine3Instance1 = Engine3.buildInstance();
|
||||
|
||||
const Engine3Instance2 = Engine3.buildInstance({ foo: 'bar' });
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@ember/engine": ["ember__engine"],
|
||||
"@ember/engine/*": ["ember__engine/*"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"instance.d.ts",
|
||||
"test/engine.ts",
|
||||
"test/engine-instance.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class AutoLocation extends Ember.AutoLocation { }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class HashLocation extends Ember.HashLocation { }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class HistoryLocation extends Ember.HistoryLocation { }
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for @ember/routing 3.0
|
||||
// Project: http://emberjs.com/
|
||||
// Definitions by: Mike North <https://github.com/mike-north>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export { default as Route } from '@ember/routing/route';
|
||||
export { default as Router } from '@ember/routing/router';
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class LinkComponent extends Ember.LinkComponent { }
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export const Location: typeof Ember.Location;
|
||||
export default Location;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class NoneLocation extends Ember.NoneLocation { }
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class Route extends Ember.Route { }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { RouterService } from 'ember';
|
||||
|
||||
export default class extends RouterService { }
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class EmberRouter extends Ember.Router { }
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
/** Static assertion that `value` has type `T` */
|
||||
// Disable tslint here b/c the generic is used to let us do a type coercion and
|
||||
// validate that coercion works for the type value "passed into" the function.
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
export declare function assertType<T>(value: T): T;
|
||||
Executable
+112
@@ -0,0 +1,112 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import Array from '@ember/array';
|
||||
import Ember from 'ember'; // currently needed for Transition
|
||||
import EmberObject from '@ember/object';
|
||||
import Controller from '@ember/controller';
|
||||
|
||||
class Post extends EmberObject {}
|
||||
|
||||
interface Posts extends Array<Post> {}
|
||||
|
||||
Route.extend({
|
||||
beforeModel(transition: Ember.Transition) {
|
||||
this.transitionTo('someOtherRoute');
|
||||
},
|
||||
});
|
||||
|
||||
Route.extend({
|
||||
afterModel(posts: Posts, transition: Ember.Transition) {
|
||||
if (posts.length === 1) {
|
||||
this.transitionTo('post.show', posts.firstObject);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Route.extend({
|
||||
actions: {
|
||||
showModal(evt: { modalName: string }) {
|
||||
this.render(evt.modalName, {
|
||||
outlet: 'modal',
|
||||
into: 'application',
|
||||
});
|
||||
},
|
||||
hideModal(evt: { modalName: string }) {
|
||||
this.disconnectOutlet({
|
||||
outlet: 'modal',
|
||||
parentView: 'application',
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Ember.Route.extend({
|
||||
model() {
|
||||
return this.modelFor('post');
|
||||
},
|
||||
});
|
||||
|
||||
Route.extend({
|
||||
queryParams: {
|
||||
memberQp: { refreshModel: true },
|
||||
},
|
||||
});
|
||||
|
||||
Route.extend({
|
||||
renderTemplate() {
|
||||
this.render('photos', {
|
||||
into: 'application',
|
||||
outlet: 'anOutletName',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Route.extend({
|
||||
renderTemplate(controller: Ember.Controller, model: {}) {
|
||||
this.render('posts', {
|
||||
view: 'someView', // the template to render, referenced by name
|
||||
into: 'application', // the template to render into, referenced by name
|
||||
outlet: 'anOutletName', // the outlet inside `options.into` to render into.
|
||||
controller: 'someControllerName', // the controller to use for this template, referenced by name
|
||||
model, // the model to set on `options.controller`.
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Route.extend({
|
||||
resetController(controller: Ember.Controller, isExiting: boolean, transition: boolean) {
|
||||
if (isExiting) {
|
||||
// controller.set('page', 1);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
class ApplicationController extends Controller {}
|
||||
declare module '@ember/controller' {
|
||||
interface Registry {
|
||||
application: ApplicationController;
|
||||
}
|
||||
}
|
||||
|
||||
Route.extend({
|
||||
setupController(controller: Controller, model: {}) {
|
||||
this._super(controller, model);
|
||||
this.controllerFor('application').set('model', model);
|
||||
},
|
||||
});
|
||||
|
||||
class RouteUsingClass extends Route.extend({
|
||||
randomProperty: 'the .extend + extends bit type-checks properly',
|
||||
}) {
|
||||
beforeModel(this: RouteUsingClass) {
|
||||
return 'beforeModel can return anything, not just promises';
|
||||
}
|
||||
intermediateTransitionWithoutModel() {
|
||||
this.intermediateTransitionTo('some-route');
|
||||
}
|
||||
intermediateTransitionWithModel() {
|
||||
this.intermediateTransitionTo('some.other.route', { });
|
||||
}
|
||||
intermediateTransitionWithMultiModel() {
|
||||
this.intermediateTransitionTo('some.other.route', 1, 2, { });
|
||||
}
|
||||
}
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
import Ember from 'ember';
|
||||
import { assertType } from './lib/assert';
|
||||
|
||||
const AppRouter = Ember.Router.extend({
|
||||
});
|
||||
|
||||
AppRouter.map(function() {
|
||||
this.route('index', { path: '/' });
|
||||
this.route('about');
|
||||
this.route('favorites', { path: '/favs' });
|
||||
this.route('posts', function() {
|
||||
this.route('index', { path: '/' });
|
||||
this.route('new');
|
||||
this.route('post', { path: '/post/:post_id', resetNamespace: true });
|
||||
this.route('comments', { resetNamespace: true }, function() {
|
||||
this.route('new');
|
||||
});
|
||||
});
|
||||
this.route('photo', { path: '/photo/:id' }, function() {
|
||||
this.route('comment', { path: '/comment/:id' });
|
||||
});
|
||||
this.route('not-found', { path: '/*path' });
|
||||
this.mount('my-engine');
|
||||
this.mount('my-engine', { as: 'some-other-engine', path: '/some-other-engine'});
|
||||
});
|
||||
|
||||
const RouterServiceConsumer = Ember.Service.extend({
|
||||
router: Ember.inject.service('router'),
|
||||
currentRouteName() {
|
||||
const x: string = Ember.get(this, 'router').currentRouteName;
|
||||
},
|
||||
currentURL() {
|
||||
const x: string = Ember.get(this, 'router').currentURL;
|
||||
},
|
||||
transitionWithoutModel() {
|
||||
Ember.get(this, 'router')
|
||||
.transitionTo('some-route');
|
||||
},
|
||||
transitionWithModel() {
|
||||
const model = Ember.Object.create();
|
||||
Ember.get(this, 'router')
|
||||
.transitionTo('some.other.route', model);
|
||||
},
|
||||
transitionWithMultiModel() {
|
||||
const model = Ember.Object.create();
|
||||
Ember.get(this, 'router')
|
||||
.transitionTo('some.other.route', model, model);
|
||||
},
|
||||
transitionWithModelAndOptions() {
|
||||
const model = Ember.Object.create();
|
||||
Ember.get(this, 'router')
|
||||
.transitionTo('index', model, { queryParams: { search: 'ember' }});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@ember/routing": ["ember__routing"],
|
||||
"@ember/routing/*": ["ember__routing/*"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"auto-location.d.ts",
|
||||
"hash-location.d.ts",
|
||||
"history-location.d.ts",
|
||||
"index.d.ts",
|
||||
"link-component.d.ts",
|
||||
"location.d.ts",
|
||||
"none-location.d.ts",
|
||||
"route.d.ts",
|
||||
"router-service.d.ts",
|
||||
"router.d.ts",
|
||||
"test/lib/assert.ts",
|
||||
"test/route.ts",
|
||||
"test/router.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import Service, { inject } from "@ember/service";
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
class FirstSvc extends Service {
|
||||
foo = 'bar';
|
||||
first() { return ''; }
|
||||
}
|
||||
const SecondSvc = Service.extend({
|
||||
foo: 'bar',
|
||||
second() { return ''; }
|
||||
});
|
||||
|
||||
class ThirdSvc extends Service.extend({
|
||||
foo: 'bar',
|
||||
third() { return ''; }
|
||||
}) { }
|
||||
|
||||
declare module '@ember/service' {
|
||||
interface Registry {
|
||||
first: FirstSvc;
|
||||
second: InstanceType<typeof SecondSvc>;
|
||||
third: ThirdSvc;
|
||||
}
|
||||
}
|
||||
|
||||
const ServiceTriplet = EmberObject.extend({
|
||||
sFirst: inject('first'),
|
||||
sSecond: inject('second'),
|
||||
sThird: inject('third'),
|
||||
unknownService: inject()
|
||||
});
|
||||
|
||||
const obj = ServiceTriplet.create();
|
||||
|
||||
obj.get('sFirst'); // $ExpectType FirstSvc
|
||||
obj.get('sSecond').second(); // $ExpectType ""
|
||||
obj.get('sThird'); // $ExpectType ThirdSvc
|
||||
obj.get('unknownService'); // $ExpectType Service
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for @ember/service 3.0
|
||||
// Project: http://emberjs.com/
|
||||
// Definitions by: Mike North <https://github.com/mike-north>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import Ember from 'ember';
|
||||
|
||||
export default class Service extends Ember.Service { }
|
||||
export const inject: typeof Ember.inject.service;
|
||||
|
||||
// A type registry for Ember `Service`s. Meant to be declaration-merged so
|
||||
// string lookups resolve to the correct type.
|
||||
// tslint:disable-next-line no-empty-interface strict-export-declare-modifiers
|
||||
interface Registry {}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@ember/service": ["ember__service"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ember__service-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
import {
|
||||
compare,
|
||||
isBlank,
|
||||
isEmpty,
|
||||
isEqual,
|
||||
isNone,
|
||||
isPresent,
|
||||
tryInvoke,
|
||||
typeOf
|
||||
} from '@ember/utils';
|
||||
import EmberObject from '@ember/object';
|
||||
|
||||
(function() {
|
||||
/** isNone */
|
||||
const maybeUndefined: string | undefined = 'not actually undefined';
|
||||
if (isNone(maybeUndefined)) {
|
||||
return;
|
||||
}
|
||||
const anotherString = maybeUndefined + 'another string';
|
||||
// TODO fix upstream in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/256
|
||||
// isNone(); // $ExpectType boolean
|
||||
isNone(null); // $ExpectType boolean
|
||||
isNone(undefined); // $ExpectType boolean
|
||||
isNone(''); // $ExpectType boolean
|
||||
isNone([]); // $ExpectType boolean
|
||||
isNone(function() {}); // $ExpectType boolean
|
||||
})();
|
||||
|
||||
(function() {
|
||||
/** tryInvoke */
|
||||
let d = new Date('03/15/2013');
|
||||
|
||||
// TODO fix enhance in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/257
|
||||
// tryInvoke(d, 'getTime'); // $ExpectType number
|
||||
// tryInvoke(d, 'setFullYear', [2014]); // $ExpectType number
|
||||
// tryInvoke(d, 'noSuchMethod', [2014]); // $ExpectType undefined
|
||||
tryInvoke(d, 'getTime');
|
||||
tryInvoke(d, 'setFullYear', [2014]);
|
||||
tryInvoke(d, 'noSuchMethod', [2014]);
|
||||
})();
|
||||
|
||||
(function() {
|
||||
/** isPresent */
|
||||
// TODO fix upstream in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/258
|
||||
// isPresent(); // $ExpectType boolean
|
||||
isPresent(null); // $ExpectType boolean
|
||||
isPresent(undefined); // $ExpectType boolean
|
||||
isPresent(''); // $ExpectType boolean
|
||||
isPresent(' '); // $ExpectType boolean
|
||||
isPresent('\n\t'); // $ExpectType boolean
|
||||
isPresent([]); // $ExpectType boolean
|
||||
isPresent({ length: 0 }); // $ExpectType boolean
|
||||
isPresent(false); // $ExpectType boolean
|
||||
isPresent(true); // $ExpectType boolean
|
||||
isPresent('string'); // $ExpectType boolean
|
||||
isPresent(0); // $ExpectType boolean
|
||||
isPresent(function() {}); // $ExpectType boolean
|
||||
isPresent({}); // $ExpectType boolean
|
||||
isPresent(false); // $ExpectType boolean
|
||||
isPresent('\n\t Hello'); // $ExpectType boolean
|
||||
isPresent([1, 2, 3]); // $ExpectType boolean
|
||||
})();
|
||||
|
||||
(function() {
|
||||
/** typeOf */
|
||||
// TODO: more specific return type in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/259
|
||||
// typeOf(null); // $ExpectType 'null'
|
||||
// typeOf(undefined); // $ExpectType 'undefined'
|
||||
// typeOf('michael'); // $ExpectType 'string'
|
||||
// // tslint:disable-next-line:no-construct
|
||||
// typeOf(new String('michael')); // $ExpectType 'string'
|
||||
// typeOf(101); // $ExpectType 'number'
|
||||
// // tslint:disable-next-line:no-construct
|
||||
// typeOf(new Number(101)); // $ExpectType 'number'
|
||||
// typeOf(true); // $ExpectType 'boolean'
|
||||
// // tslint:disable-next-line:no-construct
|
||||
// typeOf(new Boolean(true)); // $ExpectType 'boolean'
|
||||
// typeOf(() => 4); // $ExpectType 'function'
|
||||
// typeOf([1, 2, 90]); // $ExpectType 'array'
|
||||
// typeOf(/abc/); // $ExpectType 'regexp'
|
||||
// typeOf(new Date()); // $ExpectType 'date'
|
||||
// typeOf(FileList); // $ExpectType 'filelist'
|
||||
// // typeOf(EmberObject.extend()); // $ExpectType 'class'
|
||||
// // typeOf(EmberObject.create()); // $ExpectType 'instance'
|
||||
// typeOf(new Error('teamocil')); // $ExpectType 'error'
|
||||
|
||||
// TODO fix upstream in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/260
|
||||
// typeOf();
|
||||
typeOf(null);
|
||||
typeOf(undefined);
|
||||
typeOf('michael');
|
||||
// tslint:disable-next-line:no-construct
|
||||
typeOf(new String('michael'));
|
||||
typeOf(101);
|
||||
// tslint:disable-next-line:no-construct
|
||||
typeOf(new Number(101));
|
||||
typeOf(true);
|
||||
// tslint:disable-next-line:no-construct
|
||||
typeOf(new Boolean(true));
|
||||
typeOf(() => 4);
|
||||
typeOf([1, 2, 90]);
|
||||
typeOf(/abc/);
|
||||
typeOf(new Date());
|
||||
typeOf(FileList);
|
||||
typeOf(new Error('teamocil'));
|
||||
})();
|
||||
|
||||
(function() {
|
||||
/** isEqual */
|
||||
isEqual('foo', 'bar'); // $ExpectType boolean
|
||||
isEqual(14, 37); // $ExpectType boolean
|
||||
isEqual(14, '1'); // $ExpectType boolean
|
||||
isEqual(() => 4, () => 37); // $ExpectType boolean
|
||||
isEqual(14); // $ExpectError
|
||||
isEqual(); // $ExpectError
|
||||
})();
|
||||
|
||||
(function() {
|
||||
/** compare */
|
||||
compare('foo', 'bar'); // $ExpectType number
|
||||
compare(14, 37); // $ExpectType number
|
||||
compare(class {}, class {}); // $ExpectType number
|
||||
compare([], class {}); // $ExpectType number
|
||||
compare([], undefined); // $ExpectType number
|
||||
compare({}, () => 4); // $ExpectType number
|
||||
compare(14); // $ExpectError
|
||||
compare(); // $ExpectError
|
||||
})();
|
||||
|
||||
(function() {
|
||||
/** isBlank */
|
||||
|
||||
// TODO fix upstream in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/254
|
||||
// isBlank(); // $ExpectType boolean
|
||||
isBlank(null); // $ExpectType boolean
|
||||
isBlank(undefined); // $ExpectType boolean
|
||||
isBlank(''); // $ExpectType boolean
|
||||
isBlank([]); // $ExpectType boolean
|
||||
isBlank('\n\t'); // $ExpectType boolean
|
||||
isBlank(' '); // $ExpectType boolean
|
||||
isBlank({}); // $ExpectType boolean
|
||||
isBlank('\n\t Hello'); // $ExpectType boolean
|
||||
isBlank('Hello world'); // $ExpectType boolean
|
||||
isBlank([1, 2, 3]); // $ExpectType boolean
|
||||
})();
|
||||
|
||||
(function() {
|
||||
/** isEmpty */
|
||||
|
||||
// TODO fix upstream in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/255
|
||||
// isEmpty(); // $ExpectType boolean
|
||||
isEmpty(null); // $ExpectType boolean
|
||||
isEmpty(undefined); // $ExpectType boolean
|
||||
isEmpty(''); // $ExpectType boolean
|
||||
isEmpty([]); // $ExpectType boolean
|
||||
isEmpty({ size: 0 }); // $ExpectType boolean
|
||||
isEmpty({}); // $ExpectType boolean
|
||||
isEmpty('Adam Hawkins'); // $ExpectType boolean
|
||||
isEmpty([0, 1, 2]); // $ExpectType boolean
|
||||
isEmpty('\n\t'); // $ExpectType boolean
|
||||
isEmpty(' '); // $ExpectType boolean
|
||||
isEmpty({ size: 1 }); // $ExpectType boolean
|
||||
isEmpty({ size: () => 0 }); // $ExpectType boolean
|
||||
})();
|
||||
|
||||
class Foo extends EmberObject.extend({
|
||||
abc: true,
|
||||
bar() { return '123'; }
|
||||
}) {
|
||||
def: 'hello';
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// Type definitions for @ember/utils 3.0
|
||||
// Project: http://emberjs.com/
|
||||
// Definitions by: Mike North <https://github.com/mike-north>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import Ember from 'ember';
|
||||
|
||||
export const compare: typeof Ember.compare;
|
||||
export const isBlank: typeof Ember.isBlank;
|
||||
export const isEmpty: typeof Ember.isEmpty;
|
||||
export const isEqual: typeof Ember.isEqual;
|
||||
export const isNone: typeof Ember.isNone;
|
||||
export const isPresent: typeof Ember.isPresent;
|
||||
export const tryInvoke: typeof Ember.tryInvoke;
|
||||
export const typeOf: typeof Ember.typeOf;
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@ember/utils": ["ember__utils"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ember__utils-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// Heavy use of Function type in this older package.
|
||||
"ban-types": false,
|
||||
"jsdoc-format": false,
|
||||
"no-misused-new": false,
|
||||
|
||||
// these are disabled because of rfc176 module exports
|
||||
"strict-export-declare-modifiers": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-self-import": false,
|
||||
|
||||
// We use interfaces in a number of places to express things (including
|
||||
// mixins in particular, but also including extending a global
|
||||
// interface) which TS currently can't express correctly.
|
||||
"no-empty-interface": false,
|
||||
|
||||
"no-duplicate-imports": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"prefer-const": false,
|
||||
"no-void-expression": false,
|
||||
"only-arrow-functions": false,
|
||||
"no-submodule-imports": false,
|
||||
|
||||
// false positives
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
@@ -6,3 +6,5 @@ envPaths('./');
|
||||
envPaths('./', {suffix: 'test'});
|
||||
// $ExpectType Paths
|
||||
envPaths('./', {suffix: false});
|
||||
// $ExpectType Paths
|
||||
envPaths('./', {suffix: true});
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
export = envPaths;
|
||||
|
||||
declare function envPaths(name: string, opts?: { suffix: string | false }): envPaths.Paths;
|
||||
declare function envPaths(name: string, opts?: { suffix: string | boolean }): envPaths.Paths;
|
||||
|
||||
declare namespace envPaths {
|
||||
interface Paths {
|
||||
|
||||
@@ -287,6 +287,30 @@ Camera.Constants.BarCodeType;
|
||||
}
|
||||
}} />);
|
||||
};
|
||||
async (camera: CameraObject) => {
|
||||
const picture = await camera.takePictureAsync({
|
||||
quality: 0.5,
|
||||
base64: true,
|
||||
exif: true
|
||||
});
|
||||
|
||||
picture.uri;
|
||||
picture.width;
|
||||
picture.height;
|
||||
picture.exif;
|
||||
picture.base64;
|
||||
|
||||
camera.takePictureAsync({
|
||||
quality: 1,
|
||||
onPictureSaved: pic => {
|
||||
pic.uri;
|
||||
pic.width;
|
||||
pic.height;
|
||||
pic.exif;
|
||||
pic.base64;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
async () => {
|
||||
const result = await DocumentPicker.getDocumentAsync();
|
||||
|
||||
Vendored
+3
@@ -769,6 +769,9 @@ export namespace Brightness {
|
||||
*/
|
||||
export interface PictureOptions {
|
||||
quality?: number;
|
||||
base64?: boolean;
|
||||
exif?: boolean;
|
||||
onPictureSaved?: (data: PictureResponse) => void;
|
||||
}
|
||||
|
||||
export interface PictureResponse {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import translate = require('google-translate-api');
|
||||
|
||||
translate('hello', { from: 'en', to: 'zh-tw' }); // $ExpectType Promise<TranslateResult>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// Type definitions for google-translate-api 2.3
|
||||
// Project: https://github.com/matheuss/google-translate-api#readme
|
||||
// Definitions by: maple3142 <https://github.com/maple3142>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface TranslateOption {
|
||||
from?: string;
|
||||
to?: string;
|
||||
raw?: boolean;
|
||||
}
|
||||
interface TranslateResult {
|
||||
text: string;
|
||||
from: {
|
||||
language: {
|
||||
didYouMean: boolean;
|
||||
iso: string;
|
||||
}
|
||||
text: {
|
||||
autoCorrected: boolean;
|
||||
value: string;
|
||||
didYouMean: boolean;
|
||||
}
|
||||
};
|
||||
raw: string;
|
||||
}
|
||||
declare function translate(text: string, options?: TranslateOption): Promise<TranslateResult>;
|
||||
export = translate;
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": ["index.d.ts", "google-translate-api-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"semicolon": true
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,7 @@ grasp({
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
grasp({
|
||||
args: [],
|
||||
textFormat: { cyan: "cyan" }
|
||||
});
|
||||
grasp({ args: [], textFormat: { cyan: "cyan" } });
|
||||
|
||||
// $ExpectType string
|
||||
grasp.VERSION;
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import * as seq from 'gulp-sequence';
|
||||
import * as gulp from 'gulp';
|
||||
|
||||
seq.use(gulp).use(gulp).use(gulp);
|
||||
|
||||
gulp.task('x', seq('foo'));
|
||||
gulp.task('x', seq('foo', ['foo', 'bar'], 'qux'));
|
||||
gulp.task('x', seq(
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'10',
|
||||
'11',
|
||||
'12',
|
||||
'13',
|
||||
'14',
|
||||
'15',
|
||||
'16',
|
||||
'17',
|
||||
'18',
|
||||
'19',
|
||||
'20',
|
||||
'21',
|
||||
'22',
|
||||
'23',
|
||||
'24',
|
||||
'25'
|
||||
));
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
// tslint:disable-next-line:no-void-expression
|
||||
let r: undefined = <undefined> seq('foo', noop);
|
||||
// tslint:disable-next-line:no-void-expression
|
||||
r = <undefined> seq('foo', ['foo', 'bar'], 'qux', noop);
|
||||
// tslint:disable-next-line:no-void-expression
|
||||
r = <undefined> seq(
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'10',
|
||||
'11',
|
||||
'12',
|
||||
'13',
|
||||
'14',
|
||||
'15',
|
||||
'16',
|
||||
'17',
|
||||
'18',
|
||||
'19',
|
||||
'20',
|
||||
'21',
|
||||
'22',
|
||||
'23',
|
||||
'24',
|
||||
'25',
|
||||
noop
|
||||
);
|
||||
Vendored
+391
@@ -0,0 +1,391 @@
|
||||
// Type definitions for gulp-sequence 1.0
|
||||
// Project: https://github.com/teambition/gulp-sequence
|
||||
// Definitions by: Alorel <https://github.com/Alorel>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { Gulp, TaskFunction } from 'gulp';
|
||||
|
||||
declare namespace seq {
|
||||
type Step = string | string[];
|
||||
|
||||
type Done = (error?: any) => void;
|
||||
|
||||
function use(gulp: Gulp): typeof seq;
|
||||
}
|
||||
|
||||
/*
|
||||
Sequence functions (apart from the one returning TaskFunction) generated using the following (requires lodash for the padding):
|
||||
|
||||
const fnBase = `declare function seq(`;
|
||||
const argPad = _.pad('', fnBase.length, ' ');
|
||||
const maxArgs = 25;
|
||||
|
||||
const outDone = [];
|
||||
|
||||
for (let i = 1; i <= maxArgs; i++) {
|
||||
let def = [];
|
||||
for (let j = 1; j <= i; j++) {
|
||||
def.push(`s${j}: seq.Step`);
|
||||
}
|
||||
|
||||
def.push(`done: seq.Done): void;`);
|
||||
outDone.push(def.join(`,\n${argPad}`));
|
||||
}
|
||||
|
||||
console.log(fnBase + outDone.join(`\n${fnBase}`));
|
||||
*/
|
||||
|
||||
declare function seq(firstTask: seq.Step, ...additionalTasks: seq.Step[]): TaskFunction;
|
||||
|
||||
declare function seq(s1: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
s17: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
s17: seq.Step,
|
||||
s18: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
s17: seq.Step,
|
||||
s18: seq.Step,
|
||||
s19: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
s17: seq.Step,
|
||||
s18: seq.Step,
|
||||
s19: seq.Step,
|
||||
s20: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
s17: seq.Step,
|
||||
s18: seq.Step,
|
||||
s19: seq.Step,
|
||||
s20: seq.Step,
|
||||
s21: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
s17: seq.Step,
|
||||
s18: seq.Step,
|
||||
s19: seq.Step,
|
||||
s20: seq.Step,
|
||||
s21: seq.Step,
|
||||
s22: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
s17: seq.Step,
|
||||
s18: seq.Step,
|
||||
s19: seq.Step,
|
||||
s20: seq.Step,
|
||||
s21: seq.Step,
|
||||
s22: seq.Step,
|
||||
s23: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
s17: seq.Step,
|
||||
s18: seq.Step,
|
||||
s19: seq.Step,
|
||||
s20: seq.Step,
|
||||
s21: seq.Step,
|
||||
s22: seq.Step,
|
||||
s23: seq.Step,
|
||||
s24: seq.Step,
|
||||
done: seq.Done): void;
|
||||
declare function seq(s1: seq.Step,
|
||||
s2: seq.Step,
|
||||
s3: seq.Step,
|
||||
s4: seq.Step,
|
||||
s5: seq.Step,
|
||||
s6: seq.Step,
|
||||
s7: seq.Step,
|
||||
s8: seq.Step,
|
||||
s9: seq.Step,
|
||||
s10: seq.Step,
|
||||
s11: seq.Step,
|
||||
s12: seq.Step,
|
||||
s13: seq.Step,
|
||||
s14: seq.Step,
|
||||
s15: seq.Step,
|
||||
s16: seq.Step,
|
||||
s17: seq.Step,
|
||||
s18: seq.Step,
|
||||
s19: seq.Step,
|
||||
s20: seq.Step,
|
||||
s21: seq.Step,
|
||||
s22: seq.Step,
|
||||
s23: seq.Step,
|
||||
s24: seq.Step,
|
||||
s25: seq.Step,
|
||||
done: seq.Done): void;
|
||||
|
||||
export = seq;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"gulp-sequence-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+4
-8
@@ -263,19 +263,15 @@ interface Recognizer
|
||||
|
||||
canEmit():boolean;
|
||||
canRecognizeWith( otherRecognizer:Recognizer ):boolean;
|
||||
dropRecognizeWith( otherRecognizer:Recognizer ):Recognizer;
|
||||
dropRecognizeWith( otherRecognizer:string ):Recognizer;
|
||||
dropRequireFailure( otherRecognizer:Recognizer ):Recognizer;
|
||||
dropRequireFailure( otherRecognizer:string ):Recognizer;
|
||||
dropRecognizeWith( otherRecognizer:Recognizer | Recognizer[] | string):Recognizer;
|
||||
dropRequireFailure( otherRecognizer:Recognizer | Recognizer[] | string):Recognizer;
|
||||
emit( input:HammerInput ):void;
|
||||
getTouchAction():any[];
|
||||
hasRequireFailures():boolean;
|
||||
process( inputData:HammerInput ):string;
|
||||
recognize( inputData:HammerInput ):void;
|
||||
recognizeWith( otherRecognizer:Recognizer ):Recognizer;
|
||||
recognizeWith( otherRecognizer:string ):Recognizer;
|
||||
requireFailure( otherRecognizer:Recognizer ):Recognizer;
|
||||
requireFailure( otherRecognizer:string ):Recognizer;
|
||||
recognizeWith( otherRecognizer:Recognizer | Recognizer[] | string):Recognizer;
|
||||
requireFailure( otherRecognizer:Recognizer | Recognizer[] | string):Recognizer;
|
||||
reset():void;
|
||||
set( options?:RecognizerOptions ):Recognizer;
|
||||
tryEmit( input:HammerInput ):void;
|
||||
|
||||
@@ -25,9 +25,10 @@ function helmetTest() {
|
||||
*/
|
||||
function contentSecurityPolicyTest() {
|
||||
const emptyArray: string[] = [];
|
||||
const config = {
|
||||
const config: helmet.IHelmetContentSecurityPolicyConfiguration = {
|
||||
directives: {
|
||||
baseUri: ['base.example.com'],
|
||||
blockAllMixedContent: true,
|
||||
childSrc: ['child.example.com'],
|
||||
connectSrc: ['connect.example.com'],
|
||||
defaultSrc: ['*'],
|
||||
@@ -37,14 +38,20 @@ function contentSecurityPolicyTest() {
|
||||
frameSrc: emptyArray,
|
||||
imgSrc: ['images.example.com'],
|
||||
mediaSrc: ['media.example.com'],
|
||||
manifestSrc: ['manifest.example.com'],
|
||||
objectSrc: ['objects.example.com'],
|
||||
pluginTypes: emptyArray,
|
||||
prefetchSrc: ['prefetch.example.com'],
|
||||
reportUri: '/some-url',
|
||||
sandbox: emptyArray,
|
||||
reportTo: 'report.example.com',
|
||||
requireSriFor: emptyArray,
|
||||
sandbox: ['allow-presentation'],
|
||||
scriptSrc: ['scripts.example.com', function (req: express.Request, res: express.Response) {
|
||||
return "'nonce-abc123'";
|
||||
}],
|
||||
styleSrc: ['css.example.com']
|
||||
styleSrc: ['css.example.com'],
|
||||
upgradeInsecureRequests: true,
|
||||
workerSrc: ['worker.example.com']
|
||||
},
|
||||
reportOnly: false,
|
||||
setAllHeaders: false,
|
||||
|
||||
Vendored
+52
-1
@@ -35,8 +35,27 @@ declare namespace helmet {
|
||||
}
|
||||
export type HelmetCspDirectiveValue = string | IHelmetContentSecurityPolicyDirectiveFunction;
|
||||
|
||||
export type HelmetCspSandboxDirective =
|
||||
| string
|
||||
| 'allow-forms'
|
||||
| 'allow-modals'
|
||||
| 'allow-orientation-lock'
|
||||
| 'allow-pointer-lock'
|
||||
| 'allow-popups-to-escape-sandbox'
|
||||
| 'allow-popups'
|
||||
| 'allow-presentation'
|
||||
| 'allow-same-origin'
|
||||
| 'allow-scripts'
|
||||
| 'allow-top-navigation'
|
||||
|
||||
export type HelmetCspRequireSriForValue =
|
||||
| string
|
||||
| 'script'
|
||||
| 'style'
|
||||
|
||||
export interface IHelmetContentSecurityPolicyDirectives {
|
||||
baseUri?: HelmetCspDirectiveValue[];
|
||||
blockAllMixedContent?: boolean;
|
||||
childSrc?: HelmetCspDirectiveValue[];
|
||||
connectSrc?: HelmetCspDirectiveValue[];
|
||||
defaultSrc?: HelmetCspDirectiveValue[];
|
||||
@@ -45,13 +64,45 @@ declare namespace helmet {
|
||||
frameAncestors?: HelmetCspDirectiveValue[];
|
||||
frameSrc?: HelmetCspDirectiveValue[];
|
||||
imgSrc?: HelmetCspDirectiveValue[];
|
||||
manifestSrc?: HelmetCspDirectiveValue[];
|
||||
mediaSrc?: HelmetCspDirectiveValue[];
|
||||
objectSrc?: HelmetCspDirectiveValue[];
|
||||
pluginTypes?: HelmetCspDirectiveValue[];
|
||||
prefetchSrc?: HelmetCspDirectiveValue[];
|
||||
reportTo?: string;
|
||||
reportUri?: string;
|
||||
sandbox?: HelmetCspDirectiveValue[];
|
||||
requireSriFor?: HelmetCspRequireSriForValue[];
|
||||
sandbox?: HelmetCspSandboxDirective[];
|
||||
scriptSrc?: HelmetCspDirectiveValue[];
|
||||
styleSrc?: HelmetCspDirectiveValue[];
|
||||
upgradeInsecureRequests?: boolean;
|
||||
workerSrc?: HelmetCspDirectiveValue[];
|
||||
}
|
||||
|
||||
export interface IHelmetContentSecurityPolicyDirectives {
|
||||
'base-uri'?: HelmetCspDirectiveValue[];
|
||||
'block-all-mixed-content'?: boolean;
|
||||
'child-src'?: HelmetCspDirectiveValue[];
|
||||
'connect-src'?: HelmetCspDirectiveValue[];
|
||||
'default-src'?: HelmetCspDirectiveValue[];
|
||||
'font-src'?: HelmetCspDirectiveValue[];
|
||||
'form-action'?: HelmetCspDirectiveValue[];
|
||||
'frame-ancestors'?: HelmetCspDirectiveValue[];
|
||||
'frame-src'?: HelmetCspDirectiveValue[];
|
||||
'img-src'?: HelmetCspDirectiveValue[];
|
||||
'manifest-src'?: HelmetCspDirectiveValue[];
|
||||
'media-src'?: HelmetCspDirectiveValue[];
|
||||
'object-src'?: HelmetCspDirectiveValue[];
|
||||
'plugin-types'?: HelmetCspDirectiveValue[];
|
||||
'prefetch-src'?: HelmetCspDirectiveValue[];
|
||||
'report-to'?: string;
|
||||
'report-uri'?: string;
|
||||
'require-sri-for'?: HelmetCspRequireSriForValue[];
|
||||
'sandbox'?: HelmetCspSandboxDirective[];
|
||||
'script-src'?: HelmetCspDirectiveValue;
|
||||
'style-src'?: HelmetCspDirectiveValue;
|
||||
'upgrade-insecure-requests'?: boolean;
|
||||
'worker-src'?: HelmetCspDirectiveValue;
|
||||
}
|
||||
|
||||
export interface IHelmetContentSecurityPolicyConfiguration {
|
||||
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// Type definitions for jest-plugin-set 2.9
|
||||
// Project: https://github.com/negativetwelve/jest-plugins/tree/master/packages/jest-plugin-set
|
||||
// Definitions by: Jonas Heinrich <https://github.com/jonasheinrich>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function set(name: string, block: () => void): void;
|
||||
@@ -0,0 +1 @@
|
||||
set('variableA', () => {});
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"jest-plugin-set-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
+16
-1
@@ -1,6 +1,7 @@
|
||||
// Type definitions for jsdom 11.0
|
||||
// Type definitions for jsdom 11.12
|
||||
// Project: https://github.com/tmpvar/jsdom#readme
|
||||
// Definitions by: Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Johan Palmfjord <https://github.com/palmfjord>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -101,6 +102,20 @@ export type ConstructorOptions = Options & {
|
||||
* Values that are not "text/html" or an XML mime type will throw. It defaults to "text/html".
|
||||
*/
|
||||
contentType?: string;
|
||||
/**
|
||||
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
||||
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
||||
*
|
||||
* When the pretendToBeVisual option is set to true, jsdom will pretend that it is rendering and displaying
|
||||
* content.
|
||||
*/
|
||||
pretendToBeVisual?: boolean
|
||||
/**
|
||||
* The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
|
||||
* Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
|
||||
* to 5,000,000 code units per origin, as inspired by the HTML specification.
|
||||
*/
|
||||
storageQuota?: number
|
||||
};
|
||||
|
||||
export interface DOMWindow extends Window {
|
||||
|
||||
@@ -68,6 +68,14 @@ function test_beforeParse() {
|
||||
});
|
||||
}
|
||||
|
||||
function test_storageQuota() {
|
||||
new JSDOM('', { storageQuota: 1337 });
|
||||
}
|
||||
|
||||
function test_pretendToBeVisual() {
|
||||
new JSDOM('', { pretendToBeVisual: true });
|
||||
}
|
||||
|
||||
function test_serialize() {
|
||||
const dom = new JSDOM(`<!DOCTYPE html>hello`);
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@
|
||||
import { Context, Middleware } from "koa";
|
||||
|
||||
declare function convert(
|
||||
mw: (context: Context, next: () => void) => Generator
|
||||
mw: (context: Context, next: () => Promise<any>) => Generator
|
||||
): Middleware;
|
||||
|
||||
export = convert;
|
||||
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for koa-requestid 2.0
|
||||
// Project: https://github.com/seegno/koa-requestid/
|
||||
// Definitions by: Steven McDowall <https://github.com/sjmcdowall>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Middleware } from 'koa';
|
||||
|
||||
export = requestId;
|
||||
|
||||
declare function requestId(options?: {
|
||||
expose?: string;
|
||||
header?: string;
|
||||
query?: string;
|
||||
}): Middleware;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user