[ref-struct]: add opt parameter to allow create packed struct (#21932)

* [ref-struct]: add opt parameter to allow create packed struct

* Set TypeScript version to 2.2 for package depending on ref-struct
This commit is contained in:
Li Yin 2018-01-03 05:08:44 +08:00 committed by Mohamed Hegazy
parent 18b8aa88d5
commit 9dc3b08389
4 changed files with 18 additions and 3 deletions

View File

@ -2,6 +2,7 @@
// Project: https://github.com/rbranson/node-ffi
// Definitions by: Paul Loyd <https://github.com/loyd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />

View File

@ -2,6 +2,7 @@
// Project: https://github.com/TooTallNate/ref-struct
// Definitions by: Paul Loyd <https://github.com/loyd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import ref = require('ref');
@ -50,9 +51,9 @@ interface StructType extends ref.Type {
/** The struct type meta-constructor. */
declare var StructType: {
new (fields?: {}): StructType;
new (fields?: object, opt?: object): StructType;
new (fields?: any[]): StructType;
(fields?: {}): StructType;
(fields?: object, opt?: object): StructType;
(fields?: any[]): StructType;
}

View File

@ -0,0 +1,12 @@
import ref = require("ref");
import StructType = require("ref-struct");
const normalStruct = StructType({
t: ref.types.uint8,
v: ref.types.long,
});
const packedStruct = StructType({
t: ref.types.uint8,
v: ref.types.long,
}, {packed: true});

View File

@ -17,6 +17,7 @@
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
"index.d.ts",
"ref-struct-tests.ts"
]
}